---
title: "(转)最佳VIM技巧"
author: "cngump"
date: "2007-05-28T07:10:32Z"
tags: []
slug: "vim"
draft: false
lastmod: "2007-05-28T07:10:32Z"
id: 83995
url: "https://cngump.iteye.com/blog/83995"
---

;:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  
;:文档来源： [http://www.rayninfo.co.uk/vimtips.html](http://www.rayninfo.co.uk/vimtips.html)  
;:翻译参考： 没有记，请原作者见谅  
;:文档日期： 2006-10-13 11:19:04  
;:更新记录：  
;:作　　者： li3  
;:生成工具： 2Html.vim  
;:blog.asp?name=li3  
;:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

;:——————————————————————————–  
;:如果你使用的是MS-Windows,可能有的键已经被定义为Windows中的一些默认功能键。如果不  
;:想这样，请编辑$VIM\\mswin.vim  
;:——————————————————————————–  
/joe/e ;: 设置光标到匹配”joe”的末尾  
/joe/e+1 ;: 设置光标到匹配”joe”的末尾再后移一位  
/joe/s-2 ;: 设置光标到匹配”joe“的开头再前移两位  
/joe/+3 ;: 搜索“joe” 找到后将光标下移3行  
/^joe.\*fred.\*bill/ ;: 匹配以’j'开头且”joe”到”fred”到”bill”之间至少有一个字符  
/^\[A-J]\\+/ ;: 搜索行首非’A'到’J‘重复一次以上的行  
/begin\\\_.\*end ;: 多行匹配  
/fred\\\_s\*joe/i ;: 多行搜索可以是任何空白字符包括\\n,\\t等等  
/fred\\|joe ;: 搜索fred或者joe  
/.\*fred\\&.\*joe ;: 搜索同时包括fred跟joe的行  
/\\&lt;fred\\&gt;/i ;: 搜索独立的单词fred  
/\\&lt;\\d\\d\\d\\d\\&gt; ;: 搜索独立的4位数字  
/\\D\\d\\d\\d\\d\\D ;: 搜索恰好4位的数字  
/\\&lt;\\d\\\\&gt; ;: 同/\\&lt;\\d\\d\\d\\d\\&gt;  
/\\(\[^0-9]\\|^\\)%.\*% ;: 查找以非0~9数字或在行首的%%所包括的内容  
;:” 查找空行  
/^\\n\\ ;: 匹配三连续的空行  
;:” 使用正则表达式组查找  
/\\(fred\\).\*\\(joe\\).\*\\2.\*\\1  
;:” 正则表达式重复  
/^\\(\[^,]\*,\\)\\  
;:” visual 下搜索  
:vmap // y/