官术网_书友最值得收藏!

  • Mastering Vim
  • Ruslan Osipov
  • 299字
  • 2021-06-10 18:51:29

Tabs

In many modern editors, tabs are used to represent different files. While you can certainly do this in Vim, you might want to consider their original purpose.

Vim uses tabs to switch between collections of windows, allowing you to effectively have multiple workspaces. Tabs are often used to work on a slightly different problem or set of files within the same Vim session. Personally, I don't get a lot of use out of tab pages, but if you find yourself often switching context within the project or between projects, then tabs might be exactly what you're looking for.

Another reason to use tabs would be Vim's diff functionality, which works per tab. You can read more about the vimdiff in  Chapter 5, Build, Test, and Execute.

You can open a new tab with an empty buffer as follows:

:tabnew
You can open an existing file in a new tab by running :tabnew <filename>.

As you can see, tabs are displayed on the top of the screen. The tab labeled 3 farm.py is a tab with three open windows and an active buffer farm.py. The [No Name] tab is the one we just opened:

You can load a file in it in the usual way: :e <filename>. You can also switch to a desired buffer using the :b command.

To navigate between tabs, you can use the following:

  • gt or :tabnext to move to the next tab
  • gT or :tabprevious to move to the previous tab

The tabs can be closed using :tabclose or by closing all of the windows it contains (for example, with :q if it's the only window).

:tabmove N lets you place the tab after the Nth tab (or as a first tab if N is 0).

主站蜘蛛池模板: 砚山县| 防城港市| 马山县| 淮安市| 浮梁县| 宜阳县| 新昌县| 旅游| 山阴县| 柞水县| 麻栗坡县| 福泉市| 昆明市| 东方市| 保德县| 雷波县| 兴城市| 石河子市| 武胜县| 白城市| 六枝特区| 乌鲁木齐市| 元谋县| 嘉定区| 潞西市| 滦南县| 蚌埠市| 雅安市| 巴彦县| 奉新县| 星子县| 抚顺县| 禹州市| 防城港市| 城口县| 合肥市| 和平县| 桂林市| 福鼎市| 长乐市| 翼城县|