1,排版
在命令行模式下,
首先使用“gg”将光标移动到文档开头,
然后使用“v”切换到可视模式,滚动鼠标滑轮,全选内容,
最后使用“=”。
既可完成整个文档的自动排版。
2.剪切和删除
在命令模式下
首先在要标识的开始化敲入命令mx,x可以是任意字母,vim区别大小写,最好用小写,在vim和vi中通用。
'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命令(d处可以是所有VI命令)。
于是得到利用书签作cut/copy详细步骤:
Cut and Paste:
- Place the cursor at the beginning of the block you want to CUT.
- Mark it with md
- Go to the end of the block.
- Cut it with d'd
- Go to the new location that you want to PASTE those text.
- Press P.
Copy and Paste:
- Place the cursor at the beginning of the block you want to COPY.
- Mark it with my
- Go to the end of the block.
- Copy it with y'y
- Go to the new location that you want to PASTE those text.
- Press P.
The name of the mark used is related to the operation (d:delete or y:yank).
第二种是可视化模式V,只能用键盘而不是鼠标来移动光标。
Cut and paste:
- Position the cursor where you want to begin cutting.
- Press v (or upper case V if you want to cut whole lines).
- Move the cursor to the end of what you want to cut.
- Press d.
- Move to where you would like to paste.
- Press p to paste after the cursor, or P to paste before.