ITPub博客

首页 > Linux操作系统 > Linux操作系统 > [20201202]vim打开多个TAB文件.txt

[20201202]vim打开多个TAB文件.txt

原创 Linux操作系统 作者:lfree 时间:2020-12-02 11:15:28 0 删除 编辑

[20201202]vim打开多个TAB文件.txt

--//工作需要,需要一个特殊功能就是在查看文件中,打开里面涉及到的文件,而不是在打开另外的会话在执行vim打开。
--//以前我有一个工作习惯如果编辑文件很大,需要上下移动,我会使用vim的tab功能在windows下:
--//就是在vim下输入:tabedit %,就可以打开一个新的tab,使用ctrl+pgup,ctrl+pgdn切换文件,当然这样是编辑相同的文件。
--//我个人很少使用ctrl+w操作窗口系列的命令。

--// 假如文本存在如下内容:
文件位于 d:\a.txt

--//你只要先保存当前文件或者没有修改当前文件,直接移动到r字符上面,输入gf就可以打开d:\a.txt文件。
--//如果文件内容如下:
文件位于d:\a.txt

--//这样不行,可以使用V_gf命令,选中后按gf就ok。注意在windows下如果通过shift,一定要按ctrl+g切换到visual模式才有效。
--//这些并不是我需要的,我需要在一个vim的tab下打开多个文件。

--//看了一下vim文档很简单:
CTRL-W gf    Open a new tab page and edit the file name under the cursor.
        See |CTRL-W_gf|.

CTRL-W gF    Open a new tab page and edit the file name under the cursor
        and jump to the line number following the file name.
        See |CTRL-W_gF|.

--//很简单就是在前面的基础上先按ctrl-w键。
--//但是我在linux下遇到一点点小麻烦,打开多个tab后,我无法使用ctrl+pgup,ctrl+pgdn切换。在tmux下或者登录后遇到的问题都一
--//样。再次读vim文档,发现如下:

SWITCHING TO ANOTHER TAB PAGE:

Using the mouse: If the tab page line is displayed you can click in a tab page
label to switch to that tab page.  Click where there is no label to go to the
next tab page.  |'tabline'|

:tabn[ext]                *:tabn* *:tabnext* *gt*
<C-PageDown>                *CTRL-<PageDown>* *<C-PageDown>*
gt                    *i_CTRL-<PageDown>* *i_<C-PageDown>*
        Go to the next tab page.  Wraps around from the last to the
        first one.

:tabn[ext] {count}
{count}<C-PageDown>
{count}gt    Go to tab page {count}.  The first tab page has number one.


:tabp[revious]                *:tabp* *:tabprevious* *gT* *:tabN*
:tabN[ext]                *:tabNext* *CTRL-<PageUp>*
<C-PageUp>             *<C-PageUp>* *i_CTRL-<PageUp>* *i_<C-PageUp>*
gT        Go to the previous tab page.  Wraps around from the first one
        to the last one.

:tabp[revious] {count}
:tabN[ext] {count}
{count}<C-PageUp>
{count}gT    Go {count} tab pages back.  Wraps around from the first one
        to the last one.

:tabr[ewind]            *:tabfir* *:tabfirst* *:tabr* *:tabrewind*
:tabfir[st]    Go to the first tab page.

                            *:tabl* *:tablast*
:tabl[ast]    Go to the last tab page.

--//有点复杂,我仅仅需要记住{count}gt,就ok了。
--//vim命令实际上不部分仅仅知道自己熟悉的部分,如果一些命令自己不常用就很容易忘记,而且一旦知道某种技巧,一定要在实践经
--//常练习使用,形成所谓的肌肉记忆,这样就不容易忘记。
--//我估计这些功能经常使用vim编程的人会非常熟悉^_^。

--//可以做一点点小小改进就是使用map映射gf命令,这样都是使用tab打开文件:
:map gf <C-W>gf
:vmap gf <C-W>gf

--//有点不同的是linux打开后在第一个tab,而不是在最后。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-2738703/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    4019
  • 访问量
    7999299