vim 实用命令整理

  1. :1,$s/storage1/datastore1/g //替换所有storage1为datasore1
  2. ab: asap as soon as possible //定义缩写
  3. :x 等于:wq
  4. vsp 另一个文件名 //把当前窗口竖着分开
  5. set hlsearch //高亮显示查找文本
  6. :w !sudo tee % //以root方式直接保存
  7. 第二次输入一个“compiler”时, 输入“com”,然后Ctrl + n//自动补全单词
  8. $vimdiff 1.txt 2.txt //比较两个文件的不同 或 vi 1.txt->:diffthis->:vsp 2.txt->:windo diffthis ->diffoff
  9. :earlier 1m //把文件回退到1分钟以前的状态  :later //进行相反的操作
  10. Ctrl+o和Ctrl+i //在编辑文件处来回跳转
  11. Here is how to cut-and-paste or copy-and-paste text using a visual selection in Vim.

    Cut and paste:

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

    Copy and paste is performed with the same steps except for step 4 where you would press y instead of d:

    • d = delete = cut
    • y = yank = copy

你可能感兴趣的:(vim 实用命令整理)