烂笔头之vim使用(持续更新)

各种有用的插件

taglist.vim
pythoncomplete.vim
minibuffexpl.vim
HTML.vim
zencoding.vim
vimpdb.vim
omni completion
tasklist.vim
mako.vim

Mac下建议安装MacVim


各种常见操作
关于copy

1、v+移动光标可以选中文本。
2、y可以复制已经选中的文本
3、p可以粘贴


复制一行则:yy
复制当前光标所在的位置到行尾:y$
复制当前光标所在的位置到行首:y^
复制三行则:3yy,即从当前光标+下两行。

剪切文本:
用v选中文本之后可以按y进行复制,如果按d就表示剪切,之后按p进行粘贴。

剪切一行:dd
剪切当前行光标所在的位置到行尾:d$
剪切当前行光标所在的位置到行首:d^
前切三行:3dd,即从当前行+下两行被剪切了。

关于vim tab

vim -p filename ...
:tabnew         在当前标签页之后打开带空窗口的新标签页。

:tabe[dit] [++opt] [+cmd] {file}
:tabnew [++opt] [+cmd] {file}
                打开新标签页并编辑 {file},其余和 |:edit| 类同。

:tabf[ind] [++opt] [+cmd] {file}                        *:tabf* *:tabfind*
                打开新标签页并编辑 'path' 里的 {file},其余和 |:find| 类同。
                {仅当编译时加入 |+file_in_path| 特性才有效}


:tabc[lose][!]  关闭当前标签页

:tabn[ext]
:tabp[revious]


更加方便的快捷键

:tab split filename -> 这个就用tab的方式来显示多个文件 (use tab to display buffers)
gt -> 到下一个tab (go to next tab)
gT -> 到上一个tab (go to previous tab)
vim大多数东西都是可一给数字来执行的,tab也是一样
0gt ->跳到第一个tab (switch to 1st tab)
5gt -> 跳到第五个tab (switch to 5th tab)

关闭所有的tab可以使用qall的指令。


关于剪贴板

1. vim有12个粘贴板,分别是0、1、2、...、9、a、“、+;用:reg命令可以查看各个粘贴板里的内容。

      
   2. 要将vim的内容复制到某个粘贴板,选择要复制的内容(ctrl+v, 在visual模式下选择),然后按"Ny完成复制,其中N为粘贴板号(注意是按一下双引号然后按粘贴板号最后按y)
          * “号粘贴板(临时粘贴板)比较特殊,直接按y就复制到这个粘贴板中了,直接按p就粘贴这个粘贴板中的内容;
          * +号粘贴板是系统粘贴板,用"+y将内容复制到该粘贴板后可以使用Ctrl+V将其粘贴到其他文档(如firefox、gedit)中,同理,要把在其他地方用Ctrl+C或右键复制的内容复制到vim中,需要在正常模式下按"+p;

      
   3. 要将vim某个粘贴板里的内容粘贴进来,需要退出编辑模式,在正常模式按"Np,其中N为粘贴板号,如上所述,可以按"5p将5号粘贴板里的内容粘贴进来,也可以按"+p将系统全局粘贴板里的内容粘贴进来。


关于bookmark的使用

During a vi session, you can mark your place in the file with an invisible “bookmark,” perform edits elsewhere, and then return to your marked place.

在命令模式下,在你想要标识的地方敲入命令mx,表示Marks the current position with x (x can be any letter). (The original vi allows only lowercase letters. Vim distinguishes between uppercase and lowercase letters.)。这样相当于在这个地方作了个书签(锚点),之后你就可以快速的跳回来了。
'x: (Apostrophe.) Moves the cursor to the first character of the line marked by x.
`x: (Backquote.) Moves the cursor to the character marked by x.
``: (Backquotes.) Returns to the exact position of the previous mark or context after a move.
'': (Apostrophes.) Returns to the beginning of the line of the previous mark or context.
这是书签的主要作用,但是可以利用他来标识一个区域作删除。
这是因为d/y命令(事实上是所有VI命令)的一个很明显的特征:action+position。
于是得到利用书签作cut/copy详细步骤:

Cut and Paste:

  1. Place the cursor at the beginning of the block you want to CUT.
  2. Mark it with md
  3. Go to the end of the block.
  4. Cut it with d'd
  5. Go to the new location that you want to PASTE those text.
  6. Press P.

Copy and Paste:

  1. Place the cursor at the beginning of the block you want to COPY.
  2. Mark it with my
  3. Go to the end of the block.
  4. Copy it with y'y
  5. Go to the new location that you want to PASTE those text.
  6. Press P.

The name of the mark used is related to the operation (d:delete or y:yank).







   

你可能感兴趣的:(烂笔头之vim使用(持续更新))