现在的位置: 首页 > 综合 > 正文

vim的自动排版,剪切与拷贝任意区域方法

2013年08月13日 ⁄ 综合 ⁄ 共 1119字 ⁄ 字号 评论关闭

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:

  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).

 

第二种是可视化模式V,只能用键盘而不是鼠标来移动光标。

Cut and paste:

  1. Position the cursor where you want to begin cutting.
  2. Press v (or upper case V if you want to cut whole lines).
  3. Move the cursor to the end of what you want to cut.
  4. Press d.
  5. Move to where you would like to paste.
  6. Press p to paste after the cursor, or P to paste before.

抱歉!评论已关闭.