<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ko">
	<id>https://old.wiki.ubuntu-kr.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=183.96.205.193</id>
	<title>Ubuntu Korea Community Wiki - 사용자 기여 [ko]</title>
	<link rel="self" type="application/atom+xml" href="https://old.wiki.ubuntu-kr.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=183.96.205.193"/>
	<link rel="alternate" type="text/html" href="https://old.wiki.ubuntu-kr.org/index.php?title=%ED%8A%B9%EC%88%98:%EA%B8%B0%EC%97%AC/183.96.205.193"/>
	<updated>2026-10-17T02:45:47Z</updated>
	<subtitle>사용자 기여</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://old.wiki.ubuntu-kr.org/index.php?title=Vim&amp;diff=1897</id>
		<title>Vim</title>
		<link rel="alternate" type="text/html" href="https://old.wiki.ubuntu-kr.org/index.php?title=Vim&amp;diff=1897"/>
		<updated>2014-07-26T05:42:16Z</updated>

		<summary type="html">&lt;p&gt;183.96.205.193: /* About vi or vim */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About vi or vim ==&lt;br /&gt;
[[파일:http://en.wikipedia.org/wiki/Vim_%28text_editor%29#mediaviewer/File:Vim-%28logiciel%29-console.png]]&lt;br /&gt;
검은 우주 .....&lt;br /&gt;
* Vim은 유닉스 진영에서 오랜 전통을 이어온 Vi 에디터의 확장된 형태이다. Vi와 Vim의 태생이 유닉스 기반의 환경에서 만들어졌기 때문에 터미널에서 사용하도록 디자인 되었다. 100% 텍스트 환경을 자랑하는 터미널에서 사용하기 때문에 일반적인 컴퓨터 사용자&amp;lt;strike&amp;gt;정확히는 DOS에 대한 기억이 없는 컴퓨터 유저&amp;lt;/strike&amp;gt;의 경우 그 필요성이 전혀 없다.&lt;br /&gt;
&lt;br /&gt;
* 터미널에서 제공되는 텍스트 파일 편집기&amp;lt;strike&amp;gt;혹은 에디터&amp;lt;/strike&amp;gt;임에도 불구하고 유니코드를 지원하며, 다국어까지 확장되어 사용자에게 제공된다. 세계에서 이렇게 &amp;lt;strike&amp;gt;볼품없이&amp;lt;/strike&amp;gt; 완벽한 프로그램은 전례를 찾기 힘들다.&lt;br /&gt;
&lt;br /&gt;
* Vim은 'Vi improved'에 앞 글자를 조합해서 만든 이름이다. Vim의 조상인 Vi는 빌 조이가 만들어서 오랫동안 많은 개발자와 유닉스 사용자에게 사랑받은 에디터이다&amp;lt;strike&amp;gt;과연 그러한가를 emacs 유저에게 물어보자&amp;lt;/strike&amp;gt;. 빌 조이는 유닉스를 만들기 위해서 C언어를 만들었던 켄 톰슨&amp;lt;strike&amp;gt;앞의 수식어는 켄 톰슨을 향하고 있다.&amp;lt;/strike&amp;gt;의 동료이자 제자이다&amp;lt;strike&amp;gt;그렇다고 켄 톰슨이 여자는 아니다.&amp;lt;/strike&amp;gt;. 빌 조이는 BSD 유닉스의 초기 개발자이며, &amp;lt;strike&amp;gt;오라클의 제물이 되어버린&amp;lt;/strike&amp;gt; 썬 마이크로시스템즤 공동 창업자로 유명한다.&lt;br /&gt;
&lt;br /&gt;
* 당시 켄 톰슨은 멀틱스에서 영향을 받아서 만들기 시작한 유닉스 운영체제&amp;lt;strike&amp;gt;지식의 폭발!&amp;lt;/strike&amp;gt;에 파스칼이란 언어를 포팅하기 위해서 &amp;lt;strike&amp;gt;도대체 이 분들은 못하는게 뭐냐...&amp;lt;/strike&amp;gt; 빌 조이와 함께 작업을 하던 중 형편없는 텍스트 에디터 때문에 포팅 작업이 지연되자 빌 조이가 &amp;lt;strike&amp;gt;빡쳐서&amp;lt;/strike&amp;gt; Vi를 만들게 되었다.&lt;br /&gt;
&lt;br /&gt;
* 당시 유닉스에서는 ed라는 텍스트 에디터를 사용했는데, 작업 중인 행 하나만 표시되는 라인 에디터였다&amp;lt;strike&amp;gt;저기서 코딩을 했다고 한다&amp;lt;/strike&amp;gt;. 초창기 유닉스 네트워크 전송 속도가 매우 느렸기 때문에 한 번에 한 라인 밖에 보여줄 수 없었다. 이후 하드웨어가 급속도로 발전해서 &amp;lt;strike&amp;gt;정확히는 네트워크 장치가 미친듯이 발전해서&amp;lt;/strike&amp;gt; 라인 에디터가 아닌 스크린 에디터를 사용할 수 있는 환경이 되었다. 그래서 화면 전체를 사용할 수 있다고 해서 'Visual'이란 단어가 붙은 Vi에디터가 탄생하게 되었다.&amp;lt;strike&amp;gt;merge가 싫어서 git을 만들었다는걸 상기해보자... 빡침은 개발의 중요한 요소이다.&amp;lt;/strike&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Vi v.s. Emacs ==&lt;br /&gt;
* Emacs는 프로그래밍에 최적화된 에디터로 유명하다. 디버거나 다른 외부 프로그램과 연동, 플로그인 &amp;lt;strike&amp;gt;심리상담기까지 있다.&amp;lt;/strike&amp;gt;의 확장 등 기능이 강력하다. Emacs는 GPL이란 &amp;lt;strike&amp;gt;바이러스 같은&amp;lt;/strike&amp;gt; 라이센스를 선보인 '리처드 스톨만'에 의해서 탄생하였다. 리처드 스톨만이 세계에 둘 두 없을 해커라서 Emacs는 해커기질이 다분한 에디터라 할 수 있다. 심지어 현존하는 IDE에 많은 영향을 미쳤으며, 대표적으로 자바 개발자들에게 없어서는 안될 &amp;lt;strike&amp;gt;그럼에도 불구하고 인텔리J를 쓰자&amp;lt;/strike&amp;gt; 이클립스의 단축키가 Emacs와 유사한 것만 봐도 얼마나 많은 영향을 끼쳤는지 알 수 있다.&lt;br /&gt;
&lt;br /&gt;
* 누군가 이 섹션을 편집할 것이란걸 난 알고 있다. 자... 시작해보라!&lt;br /&gt;
&lt;br /&gt;
== Vim의 특징(확실한건 Vi보단 좋다.) ==&lt;br /&gt;
* 문법 검사 기능 및 색상 강조 기능&lt;br /&gt;
* 향상된 자동 완성 기능 제공&lt;br /&gt;
* 유니코드와 국제화 규격(i18n) 지원&lt;br /&gt;
* 여러 파일 동시 편집 가능(탭 페이지)&lt;br /&gt;
* 정규식 기능 및 grep 기능 내장&lt;br /&gt;
* 제한적인 네트워크 기능 제공&lt;br /&gt;
* undo 기능 대폭 강화&lt;br /&gt;
&lt;br /&gt;
== Vim 설치 ==&lt;br /&gt;
* 우분투 : sudo apt-get install vim&lt;br /&gt;
* 센토스 : sudo yum install vim-enhanced&lt;br /&gt;
* 윈도우 : http://www.vim.org에서 exe파일 다운로드 후 더블 클릭&lt;br /&gt;
* 맥OSX  : 설치되어 있음&lt;br /&gt;
&lt;br /&gt;
== Vim TIP ==&lt;br /&gt;
* 다음은 vim의 팁이다. 원본은 http://zzapper.co.uk/vimtips.html 에서 볼 수 있다.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
------------------------------------------------------------------------------&lt;br /&gt;
&amp;quot; new items marked [N] , corrected items marked [C]&lt;br /&gt;
&amp;quot; *best-searching*&lt;br /&gt;
/joe/e                      : cursor set to End of match&lt;br /&gt;
3/joe/e+1                   : find 3rd joe cursor set to End of match plus 1 [C]&lt;br /&gt;
/joe/s-2                    : cursor set to Start of match minus 2&lt;br /&gt;
/joe/+3                     : find joe move cursor 3 lines down&lt;br /&gt;
/^joe.*fred.*bill/          : find joe AND fred AND Bill (Joe at start of line)&lt;br /&gt;
/^[A-J]/                    : search for lines beginning with one or more A-J&lt;br /&gt;
/begin\_.*end               : search over possible multiple lines&lt;br /&gt;
/fred\_s*joe/               : any whitespace including newline [C]&lt;br /&gt;
/fred\|joe                  : Search for FRED OR JOE&lt;br /&gt;
/.*fred\&amp;amp;.*joe              : Search for FRED AND JOE in any ORDER!&lt;br /&gt;
/\&amp;lt;fred\&amp;gt;/                  : search for fred but not alfred or frederick [C]&lt;br /&gt;
/\&amp;lt;\d\d\d\d\&amp;gt;               : Search for exactly 4 digit numbers&lt;br /&gt;
/\D\d\d\d\d\D               : Search for exactly 4 digit numbers&lt;br /&gt;
/\&amp;lt;\d\{4}\&amp;gt;                 : same thing&lt;br /&gt;
/\([^0-9]\|^\)%.*%          : Search for absence of a digit or beginning of line&lt;br /&gt;
&amp;quot; finding empty lines&lt;br /&gt;
/^\n\{3}                    : find 3 empty lines&lt;br /&gt;
/^str.*\nstr                : find 2 successive lines starting with str&lt;br /&gt;
/\(^str.*\n\)\{2}           : find 2 successive lines starting with str&lt;br /&gt;
&amp;quot; using rexexp memory in a search find fred.*joe.*joe.*fred *C*&lt;br /&gt;
/\(fred\).*\(joe\).*\2.*\1&lt;br /&gt;
&amp;quot; Repeating the Regexp (rather than what the Regexp finds)&lt;br /&gt;
/^\([^,]*,\)\{8}&lt;br /&gt;
&amp;quot; visual searching&lt;br /&gt;
:vmap // y/&amp;lt;C-R&amp;gt;&amp;quot;&amp;lt;CR&amp;gt;       : search for visually highlighted text&lt;br /&gt;
:vmap &amp;lt;silent&amp;gt; //    y/&amp;lt;C-R&amp;gt;=escape(@&amp;quot;, '\\/.*$^~[]')&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt; : with spec chars&lt;br /&gt;
&amp;quot; \zs and \ze regex delimiters :h /\zs&lt;br /&gt;
/&amp;lt;\zs[^&amp;gt;]*\ze&amp;gt;              : search for tag contents, ignoring chevrons&lt;br /&gt;
&amp;quot; zero-width :h /\@=&lt;br /&gt;
/&amp;lt;\@&amp;lt;=[^&amp;gt;]*&amp;gt;\@=             : search for tag contents, ignoring chevrons&lt;br /&gt;
/&amp;lt;\@&amp;lt;=\_[^&amp;gt;]*&amp;gt;\@=           : search for tags across possible multiple lines&lt;br /&gt;
&amp;quot; searching over multiple lines \_ means including newline&lt;br /&gt;
/&amp;lt;!--\_p\{-}--&amp;gt;                   : search for multiple line comments&lt;br /&gt;
/fred\_s*joe/                     : any whitespace including newline *C*&lt;br /&gt;
/bugs\(\_.\)*bunny                : bugs followed by bunny anywhere in file&lt;br /&gt;
:h \_                             : help&lt;br /&gt;
&amp;quot; search for declaration of subroutine/function under cursor&lt;br /&gt;
:nmap gx yiw/^\(sub\&amp;lt;bar&amp;gt;function\)\s\+&amp;lt;C-R&amp;gt;&amp;quot;&amp;lt;CR&amp;gt;&lt;br /&gt;
&amp;quot; multiple file search&lt;br /&gt;
:bufdo /searchstr/                : use :rewind to recommence search&lt;br /&gt;
&amp;quot; multiple file search better but cheating&lt;br /&gt;
:bufdo %s/searchstr/&amp;amp;/gic   : say n and then a to stop&lt;br /&gt;
&amp;quot; How to search for a URL without backslashing&lt;br /&gt;
?http://www.vim.org/        : (first) search BACKWARDS!!! clever huh!&lt;br /&gt;
&amp;quot; Specify what you are NOT searching for (vowels)&lt;br /&gt;
/\c\v([^aeiou]&amp;amp;\a){4}       : search for 4 consecutive consonants&lt;br /&gt;
/\%&amp;gt;20l\%&amp;lt;30lgoat           : Search for goat between lines 20 and 30 [N]&lt;br /&gt;
/^.\{-}home.\{-}\zshome/e   : match only the 2nd occurence in a line of &amp;quot;home&amp;quot; [N]&lt;br /&gt;
:%s/home.\{-}\zshome/alone  : Substitute only the occurrence of home in any line [N]&lt;br /&gt;
&amp;quot; find str but not on lines containing tongue&lt;br /&gt;
^\(.*tongue.*\)\@!.*nose.*$&lt;br /&gt;
\v^((tongue)@!.)*nose((tongue)@!.)*$&lt;br /&gt;
.*nose.*\&amp;amp;^\%(\%(tongue\)\@!.\)*$ &lt;br /&gt;
:v/tongue/s/nose/&amp;amp;/gic&lt;br /&gt;
'a,'bs/extrascost//gc       : trick: restrict search to between markers (answer n) [N]&lt;br /&gt;
&amp;quot;----------------------------------------&lt;br /&gt;
&amp;quot; *best-substitution*&lt;br /&gt;
:%s/fred/joe/igc            : general substitute command&lt;br /&gt;
:%s//joe/igc                : Substitute what you last searched for [N]&lt;br /&gt;
:%s/~/sue/igc               : Substitute your last replacement string [N]&lt;br /&gt;
:%s/\r//g                   : Delete DOS returns ^M&lt;br /&gt;
&amp;quot; Is your Text File jumbled onto one line? use following&lt;br /&gt;
:%s/\r/\r/g                 : Turn DOS returns ^M into real returns&lt;br /&gt;
:%s=  *$==                  : delete end of line blanks&lt;br /&gt;
:%s= \+$==                  : Same thing&lt;br /&gt;
:%s#\s*\r\?$##              : Clean both trailing spaces AND DOS returns&lt;br /&gt;
:%s#\s*\r*$##               : same thing&lt;br /&gt;
&amp;quot; deleting empty lines&lt;br /&gt;
:%s/^\n\{3}//               : delete blocks of 3 empty lines&lt;br /&gt;
:%s/^\n\+/\r/               : compressing empty lines&lt;br /&gt;
:%s#&amp;lt;[^&amp;gt;]\+&amp;gt;##g             : delete html tags, leave text (non-greedy)&lt;br /&gt;
:%s#&amp;lt;\_.\{-1,}&amp;gt;##g          : delete html tags possibly multi-line (non-greedy)&lt;br /&gt;
:%s#.*\(\d\+hours\).*#\1#   : Delete all but memorised string (\1) [N]&lt;br /&gt;
&amp;quot; parse xml/soap &lt;br /&gt;
%s#&amp;gt;&amp;lt;\([^/]\)#&amp;gt;\r&amp;lt;\1#g      : split jumbled up XML file into one tag per line [N]&lt;br /&gt;
%s/&amp;lt;/\r&amp;amp;/g                  : simple split of html/xml/soap  [N]&lt;br /&gt;
:%s#&amp;lt;[^/]#\r&amp;amp;#gic           : simple split of html/xml/soap  but not closing tag [N]&lt;br /&gt;
:%s#&amp;lt;[^/]#\r&amp;amp;#gi            : parse on open xml tag [N]&lt;br /&gt;
:%s#\[\d\+\]#\r&amp;amp;#g          : parse on numbered array elements [1] [N]&lt;br /&gt;
&amp;quot; VIM Power Substitute&lt;br /&gt;
:'a,'bg/fred/s/dick/joe/igc : VERY USEFUL&lt;br /&gt;
&amp;quot; duplicating columns&lt;br /&gt;
:%s= [^ ]\+$=&amp;amp;&amp;amp;=            : duplicate end column&lt;br /&gt;
:%s= \f\+$=&amp;amp;&amp;amp;=              : Dupicate filename&lt;br /&gt;
:%s= \S\+$=&amp;amp;&amp;amp;               : usually the same&lt;br /&gt;
&amp;quot; memory&lt;br /&gt;
:%s#example#&amp;amp; = &amp;amp;#gic        : duplicate entire matched string [N]&lt;br /&gt;
:%s#.*\(tbl_\w\+\).*#\1#    : extract list of all strings tbl_* from text  [NC]&lt;br /&gt;
:s/\(.*\):\(.*\)/\2 : \1/   : reverse fields separated by :&lt;br /&gt;
:%s/^\(.*\)\n\1$/\1/        : delete duplicate lines&lt;br /&gt;
:%s/^\(.*\)\(\n\1\)\+$/\1/  : delete multiple duplicate lines [N]&lt;br /&gt;
&amp;quot; non-greedy matching \{-}&lt;br /&gt;
:%s/^.\{-}pdf/new.pdf/      : delete to 1st occurence of pdf only (non-greedy)&lt;br /&gt;
%s#^.\{-}\([0-9]\{3,4\}serial\)#\1#gic : delete up to 123serial or 1234serial [N]&lt;br /&gt;
&amp;quot; use of optional atom \?&lt;br /&gt;
:%s#\&amp;lt;[zy]\?tbl_[a-z_]\+\&amp;gt;#\L&amp;amp;#gc : lowercase with optional leading characters&lt;br /&gt;
&amp;quot; over possibly many lines&lt;br /&gt;
:%s/&amp;lt;!--\_.\{-}--&amp;gt;//        : delete possibly multi-line comments&lt;br /&gt;
:help /\{-}                 : help non-greedy&lt;br /&gt;
&amp;quot; substitute using a register&lt;br /&gt;
:s/fred/&amp;lt;c-r&amp;gt;a/g            : sub &amp;quot;fred&amp;quot; with contents of register &amp;quot;a&amp;quot;&lt;br /&gt;
:s/fred/&amp;lt;c-r&amp;gt;asome_text&amp;lt;c-r&amp;gt;s/g  &lt;br /&gt;
:s/fred/\=@a/g              : better alternative as register not displayed (not *) [C]&lt;br /&gt;
&amp;quot; multiple commands on one line&lt;br /&gt;
:%s/\f\+\.gif\&amp;gt;/\r&amp;amp;\r/g | v/\.gif$/d | %s/gif/jpg/&lt;br /&gt;
:%s/a/but/gie|:update|:next : then use @: to repeat&lt;br /&gt;
&amp;quot; ORing&lt;br /&gt;
:%s/goat\|cow/sheep/gc      : ORing (must break pipe)&lt;br /&gt;
:'a,'bs#\[\|\]##g           : remove [] from lines between markers a and b [N]&lt;br /&gt;
:%s/\v(.*\n){5}/&amp;amp;\r         : insert a blank line every 5 lines [N]&lt;br /&gt;
&amp;quot; Calling a VIM function&lt;br /&gt;
:s/__date__/\=strftime(&amp;quot;%c&amp;quot;)/ : insert datestring&lt;br /&gt;
:inoremap \zd &amp;lt;C-R&amp;gt;=strftime(&amp;quot;%d%b%y&amp;quot;)&amp;lt;CR&amp;gt;    : insert date eg 31Jan11 [N]&lt;br /&gt;
&amp;quot; Working with Columns sub any str1 in col3&lt;br /&gt;
:%s:\(\(\w\+\s\+\)\{2}\)str1:\1str2:&lt;br /&gt;
&amp;quot; Swapping first &amp;amp; last column (4 columns)&lt;br /&gt;
:%s:\(\w\+\)\(.*\s\+\)\(\w\+\)$:\3\2\1:&lt;br /&gt;
&amp;quot; format a mysql query &lt;br /&gt;
:%s#\&amp;lt;from\&amp;gt;\|\&amp;lt;where\&amp;gt;\|\&amp;lt;left join\&amp;gt;\|\&amp;lt;\inner join\&amp;gt;#\r&amp;amp;#g&lt;br /&gt;
&amp;quot; filter all form elements into paste register&lt;br /&gt;
:redir @*|sil exec 'g#&amp;lt;\(input\|select\|textarea\|/\=form\)\&amp;gt;#p'|redir END&lt;br /&gt;
:nmap ,z :redir @*&amp;lt;Bar&amp;gt;sil exec 'g@&amp;lt;\(input\&amp;lt;Bar&amp;gt;select\&amp;lt;Bar&amp;gt;textarea\&amp;lt;Bar&amp;gt;/\=form\)\&amp;gt;@p'&amp;lt;Bar&amp;gt;redir END&amp;lt;CR&amp;gt;&lt;br /&gt;
&amp;quot; substitute string in column 30 [N]&lt;br /&gt;
:%s/^\(.\{30\}\)xx/\1yy/&lt;br /&gt;
&amp;quot; decrement numbers by 3&lt;br /&gt;
:%s/\d\+/\=(submatch(0)-3)/&lt;br /&gt;
&amp;quot; increment numbers by 6 on certain lines only&lt;br /&gt;
:g/loc\|function/s/\d/\=submatch(0)+6/&lt;br /&gt;
&amp;quot; better&lt;br /&gt;
:%s#txtdev\zs\d#\=submatch(0)+1#g&lt;br /&gt;
:h /\zs&lt;br /&gt;
&amp;quot; increment only numbers gg\d\d  by 6 (another way)&lt;br /&gt;
:%s/\(gg\)\@&amp;lt;=\d\+/\=submatch(0)+6/&lt;br /&gt;
:h zero-width&lt;br /&gt;
&amp;quot; rename a string with an incrementing number&lt;br /&gt;
:let i=10 | 'a,'bg/Abc/s/yy/\=i/ |let i=i+1 # convert yy to 10,11,12 etc&lt;br /&gt;
&amp;quot; as above but more precise&lt;br /&gt;
:let i=10 | 'a,'bg/Abc/s/xx\zsyy\ze/\=i/ |let i=i+1 # convert xxyy to xx11,xx12,xx13&lt;br /&gt;
&amp;quot; find replacement text, put in memory, then use \zs to simplify substitute&lt;br /&gt;
:%s/&amp;quot;\([^.]\+\).*\zsxx/\1/&lt;br /&gt;
&amp;quot; Pull word under cursor into LHS of a substitute&lt;br /&gt;
:nmap &amp;lt;leader&amp;gt;z :%s#\&amp;lt;&amp;lt;c-r&amp;gt;=expand(&amp;quot;&amp;lt;cword&amp;gt;&amp;quot;)&amp;lt;cr&amp;gt;\&amp;gt;#&lt;br /&gt;
&amp;quot; Pull Visually Highlighted text into LHS of a substitute&lt;br /&gt;
:vmap &amp;lt;leader&amp;gt;z :&amp;lt;C-U&amp;gt;%s/\&amp;lt;&amp;lt;c-r&amp;gt;*\&amp;gt;/&lt;br /&gt;
&amp;quot; substitute singular or plural&lt;br /&gt;
:'a,'bs/bucket\(s\)*/bowl\1/gic   [N]&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; all following performing similar task, substitute within substitution&lt;br /&gt;
&amp;quot; Multiple single character substitution in a portion of line only&lt;br /&gt;
:%s,\(all/.*\)\@&amp;lt;=/,_,g     : replace all / with _ AFTER &amp;quot;all/&amp;quot;&lt;br /&gt;
&amp;quot; Same thing&lt;br /&gt;
:s#all/\zs.*#\=substitute(submatch(0), '/', '_', 'g')#&lt;br /&gt;
&amp;quot; Substitute by splitting line, then re-joining&lt;br /&gt;
:s#all/#&amp;amp;^M#|s#/#_#g|-j!&lt;br /&gt;
&amp;quot; Substitute inside substitute&lt;br /&gt;
:%s/.*/\='cp '.submatch(0).' all/'.substitute(submatch(0),'/','_','g')/&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; *best-global* command &lt;br /&gt;
:g/gladiolli/#              : display with line numbers (YOU WANT THIS!)&lt;br /&gt;
:g/fred.*joe.*dick/         : display all lines fred,joe &amp;amp; dick&lt;br /&gt;
:g/\&amp;lt;fred\&amp;gt;/                : display all lines fred but not freddy&lt;br /&gt;
:g/^\s*$/d                  : delete all blank lines&lt;br /&gt;
:g!/^dd/d                   : delete lines not containing string&lt;br /&gt;
:v/^dd/d                    : delete lines not containing string&lt;br /&gt;
:g/joe/,/fred/d             : not line based (very powerfull)&lt;br /&gt;
:g/fred/,/joe/j             : Join Lines [N]&lt;br /&gt;
:g/-------/.-10,.d          : Delete string &amp;amp; 10 previous lines&lt;br /&gt;
:g/{/ ,/}/- s/\n\+/\r/g     : Delete empty lines but only between {...}&lt;br /&gt;
:v/\S/d                     : Delete empty lines (and blank lines ie whitespace)&lt;br /&gt;
:v/./,/./-j                 : compress empty lines&lt;br /&gt;
:g/^$/,/./-j                : compress empty lines&lt;br /&gt;
:g/&amp;lt;input\|&amp;lt;form/p          : ORing&lt;br /&gt;
:g/^/put_                   : double space file (pu = put)&lt;br /&gt;
:g/^/m0                     : Reverse file (m = move)&lt;br /&gt;
:g/^/m$                     : No effect! [N]&lt;br /&gt;
:'a,'bg/^/m'b               : Reverse a section a to b&lt;br /&gt;
:g/^/t.                     : duplicate every line&lt;br /&gt;
:g/fred/t$                  : copy (transfer) lines matching fred to EOF&lt;br /&gt;
:g/stage/t'a                : copy (transfer) lines matching stage to marker a (cannot use .) [C]&lt;br /&gt;
:g/^Chapter/t.|s/./-/g      : Automatically underline selecting headings [N]&lt;br /&gt;
:g/\(^I[^^I]*\)\{80}/d      : delete all lines containing at least 80 tabs&lt;br /&gt;
&amp;quot; perform a substitute on every other line&lt;br /&gt;
:g/^/ if line('.')%2|s/^/zz / &lt;br /&gt;
&amp;quot; match all lines containing &amp;quot;somestr&amp;quot; between markers a &amp;amp; b&lt;br /&gt;
&amp;quot; copy after line containing &amp;quot;otherstr&amp;quot;&lt;br /&gt;
:'a,'bg/somestr/co/otherstr/ : co(py) or mo(ve)&lt;br /&gt;
&amp;quot; as above but also do a substitution&lt;br /&gt;
:'a,'bg/str1/s/str1/&amp;amp;&amp;amp;&amp;amp;/|mo/str2/&lt;br /&gt;
:%norm jdd                  : delete every other line&lt;br /&gt;
&amp;quot; incrementing numbers (type &amp;lt;c-a&amp;gt; as 5 characters)&lt;br /&gt;
:.,$g/^\d/exe &amp;quot;norm! \&amp;lt;c-a&amp;gt;&amp;quot;: increment numbers&lt;br /&gt;
:'a,'bg/\d\+/norm! ^A       : increment numbers&lt;br /&gt;
&amp;quot; storing glob results (note must use APPEND) you need to empty reg a first with qaq. &lt;br /&gt;
&amp;quot;save results to a register/paste buffer&lt;br /&gt;
:g/fred/y A                 : append all lines fred to register a&lt;br /&gt;
:g/fred/y A | :let @*=@a    : put into paste buffer&lt;br /&gt;
:let @a=''|g/Barratt/y A |:let @*=@a&lt;br /&gt;
&amp;quot; filter lines to a file (file must already exist)&lt;br /&gt;
:'a,'bg/^Error/ . w &amp;gt;&amp;gt; errors.txt&lt;br /&gt;
&amp;quot; duplicate every line in a file wrap a print '' around each duplicate&lt;br /&gt;
:g/./yank|put|-1s/'/&amp;quot;/g|s/.*/Print '&amp;amp;'/&lt;br /&gt;
&amp;quot; replace string with contents of a file, -d deletes the &amp;quot;mark&amp;quot;&lt;br /&gt;
:g/^MARK$/r tmp.txt | -d&lt;br /&gt;
&amp;quot; display prettily&lt;br /&gt;
:g/&amp;lt;pattern&amp;gt;/z#.5           : display with context&lt;br /&gt;
:g/&amp;lt;pattern&amp;gt;/z#.5|echo &amp;quot;==========&amp;quot;  : display beautifully&lt;br /&gt;
&amp;quot; Combining g// with normal mode commands&lt;br /&gt;
:g/|/norm 2f|r*                      : replace 2nd | with a star&lt;br /&gt;
&amp;quot;send output of previous global command to a new window&lt;br /&gt;
:nmap &amp;lt;F3&amp;gt;  :redir @a&amp;lt;CR&amp;gt;:g//&amp;lt;CR&amp;gt;:redir END&amp;lt;CR&amp;gt;:new&amp;lt;CR&amp;gt;:put! a&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&lt;br /&gt;
&amp;quot;----------------------------------------&lt;br /&gt;
&amp;quot; *Best-Global-combined-with-substitute* (*power-editing*)&lt;br /&gt;
:'a,'bg/fred/s/joe/susan/gic :  can use memory to extend matching&lt;br /&gt;
:/fred/,/joe/s/fred/joe/gic :  non-line based (ultra)&lt;br /&gt;
:/biz/,/any/g/article/s/wheel/bucket/gic:  non-line based [N]&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Find fred before beginning search for joe&lt;br /&gt;
:/fred/;/joe/-2,/sid/+3s/sally/alley/gIC&lt;br /&gt;
&amp;quot;----------------------------------------&lt;br /&gt;
&amp;quot; create a new file for each line of file eg 1.txt,2.txt,3,txt etc&lt;br /&gt;
:g/^/exe &amp;quot;.w &amp;quot;.line(&amp;quot;.&amp;quot;).&amp;quot;.txt&amp;quot;&lt;br /&gt;
&amp;quot;----------------------------------------&lt;br /&gt;
&amp;quot; chain an external command&lt;br /&gt;
:.g/^/ exe &amp;quot;.!sed 's/N/X/'&amp;quot; | s/I/Q/    [N]&lt;br /&gt;
&amp;quot;----------------------------------------&lt;br /&gt;
&amp;quot; Operate until string found [N]&lt;br /&gt;
d/fred/                                :delete until fred&lt;br /&gt;
y/fred/                                :yank until fred&lt;br /&gt;
c/fred/e                               :change until fred end&lt;br /&gt;
v12|                                   : visualise/change/delete to column 12 [N]&lt;br /&gt;
&amp;quot;----------------------------------------&lt;br /&gt;
&amp;quot; Summary of editing repeats [N]&lt;br /&gt;
.      last edit (magic dot)&lt;br /&gt;
:&amp;amp;     last substitute&lt;br /&gt;
:%&amp;amp;    last substitute every line&lt;br /&gt;
:%&amp;amp;gic last substitute every line confirm&lt;br /&gt;
g%     normal mode repeat last substitute&lt;br /&gt;
g&amp;amp;     last substitute on all lines&lt;br /&gt;
@@     last recording&lt;br /&gt;
@:     last command-mode command&lt;br /&gt;
:!!    last :! command&lt;br /&gt;
:~     last substitute&lt;br /&gt;
:help repeating&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Summary of repeated searches&lt;br /&gt;
;      last f, t, F or T&lt;br /&gt;
,      last f, t, F or T in opposite direction&lt;br /&gt;
n      last / or ? search&lt;br /&gt;
N      last / or ? search in opposite direction&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; *Absolutely-essential*&lt;br /&gt;
----------------------------------------&lt;br /&gt;
* # g* g#           : find word under cursor (&amp;lt;cword&amp;gt;) (forwards/backwards)&lt;br /&gt;
%                   : match brackets {}[]()&lt;br /&gt;
.                   : repeat last modification &lt;br /&gt;
@:                  : repeat last : command (then @@)&lt;br /&gt;
matchit.vim         : % now matches tags &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;script&amp;gt; &amp;lt;?php etc&lt;br /&gt;
&amp;lt;C-N&amp;gt;&amp;lt;C-P&amp;gt;          : word completion in insert mode&lt;br /&gt;
&amp;lt;C-X&amp;gt;&amp;lt;C-L&amp;gt;          : Line complete SUPER USEFUL&lt;br /&gt;
/&amp;lt;C-R&amp;gt;&amp;lt;C-W&amp;gt;         : Pull &amp;lt;cword&amp;gt; onto search/command line&lt;br /&gt;
/&amp;lt;C-R&amp;gt;&amp;lt;C-A&amp;gt;         : Pull &amp;lt;CWORD&amp;gt; onto search/command line&lt;br /&gt;
:set ignorecase     : you nearly always want this&lt;br /&gt;
:set smartcase      : overrides ignorecase if uppercase used in search string (cool)&lt;br /&gt;
:syntax on          : colour syntax in Perl,HTML,PHP etc&lt;br /&gt;
:set syntax=perl    : force syntax (usually taken from file extension)&lt;br /&gt;
:h regexp&amp;lt;C-D&amp;gt;      : type control-D and get a list all help topics containing&lt;br /&gt;
                      regexp (plus use TAB to Step thru list)&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; MAKE IT EASY TO UPDATE/RELOAD _vimrc&lt;br /&gt;
:nmap ,s :source $VIM/_vimrc&lt;br /&gt;
:nmap ,v :e $VIM/_vimrc&lt;br /&gt;
:e $MYVIMRC         : edits your _vimrc whereever it might be  [N]&lt;br /&gt;
&amp;quot; How to have a variant in your .vimrc for different PCs [N]&lt;br /&gt;
if $COMPUTERNAME == &amp;quot;NEWPC&amp;quot;&lt;br /&gt;
ab mypc vista&lt;br /&gt;
else&lt;br /&gt;
ab mypc dell25&lt;br /&gt;
endif&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; splitting windows&lt;br /&gt;
:vsplit other.php       # vertically split current file with other.php [N]&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot;VISUAL MODE (easy to add other HTML Tags)&lt;br /&gt;
:vmap sb &amp;quot;zdi&amp;lt;b&amp;gt;&amp;lt;C-R&amp;gt;z&amp;lt;/b&amp;gt;&amp;lt;ESC&amp;gt;  : wrap &amp;lt;b&amp;gt;&amp;lt;/b&amp;gt; around VISUALLY selected Text&lt;br /&gt;
:vmap st &amp;quot;zdi&amp;lt;?= &amp;lt;C-R&amp;gt;z ?&amp;gt;&amp;lt;ESC&amp;gt;  : wrap &amp;lt;?=   ?&amp;gt; around VISUALLY selected Text&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot;vim 7 tabs&lt;br /&gt;
vim -p fred.php joe.php             : open files in tabs&lt;br /&gt;
:tabe fred.php                      : open fred.php in a new tab&lt;br /&gt;
:tab ball                           : tab open files&lt;br /&gt;
:close                              : close a tab but leave the buffer *N*&lt;br /&gt;
&amp;quot; vim 7 forcing use of tabs from .vimrc&lt;br /&gt;
:nnoremap gf &amp;lt;C-W&amp;gt;gf&lt;br /&gt;
:cab      e  tabe&lt;br /&gt;
:tab sball                           : retab all files in buffer (repair) [N]&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Exploring&lt;br /&gt;
:e .                            : file explorer&lt;br /&gt;
:Exp(lore)                      : file explorer note capital Ex&lt;br /&gt;
:Sex(plore)                     : file explorer in split window&lt;br /&gt;
:browse e                       : windows style browser&lt;br /&gt;
:ls                             : list of buffers&lt;br /&gt;
:cd ..                          : move to parent directory&lt;br /&gt;
:args                           : list of files&lt;br /&gt;
:pwd                            : Print Working Directory (current directory) [N]&lt;br /&gt;
:args *.php                     : open list of files (you need this!)&lt;br /&gt;
:lcd %:p:h                      : change to directory of current file&lt;br /&gt;
:autocmd BufEnter * lcd %:p:h   : change to directory of current file automatically (put in _vimrc)&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Changing Case&lt;br /&gt;
guu                             : lowercase line&lt;br /&gt;
gUU                             : uppercase line&lt;br /&gt;
Vu                              : lowercase line&lt;br /&gt;
VU                              : uppercase line&lt;br /&gt;
g~~                             : flip case line&lt;br /&gt;
vEU                             : Upper Case Word&lt;br /&gt;
vE~                             : Flip Case Word&lt;br /&gt;
ggguG                           : lowercase entire file&lt;br /&gt;
&amp;quot; Titlise Visually Selected Text (map for .vimrc)&lt;br /&gt;
vmap ,c :s/\&amp;lt;\(.\)\(\k*\)\&amp;gt;/\u\1\L\2/g&amp;lt;CR&amp;gt;&lt;br /&gt;
&amp;quot; Title Case A Line Or Selection (better)&lt;br /&gt;
vnoremap &amp;lt;F6&amp;gt; :s/\%V\&amp;lt;\(\w\)\(\w*\)\&amp;gt;/\u\1\L\2/ge&amp;lt;cr&amp;gt; [N]&lt;br /&gt;
&amp;quot; titlise a line&lt;br /&gt;
nmap ,t :s/.*/\L&amp;amp;/&amp;lt;bar&amp;gt;:s/\&amp;lt;./\u&amp;amp;/g&amp;lt;cr&amp;gt;  [N]&lt;br /&gt;
&amp;quot; Uppercase first letter of sentences&lt;br /&gt;
:%s/[.!?]\_s\+\a/\U&amp;amp;\E/g&lt;br /&gt;
----------------------------------------&lt;br /&gt;
gf                              : open file name under cursor (SUPER)&lt;br /&gt;
:nnoremap gF :view &amp;lt;cfile&amp;gt;&amp;lt;cr&amp;gt;  : open file under cursor, create if necessary&lt;br /&gt;
ga                              : display hex,ascii value of char under cursor&lt;br /&gt;
ggVGg?                          : rot13 whole file&lt;br /&gt;
ggg?G                           : rot13 whole file (quicker for large file)&lt;br /&gt;
:8 | normal VGg?                : rot13 from line 8&lt;br /&gt;
:normal 10GVGg?                 : rot13 from line 8&lt;br /&gt;
&amp;lt;C-A&amp;gt;,&amp;lt;C-X&amp;gt;                     : increment,decrement number under cursor&lt;br /&gt;
                                  win32 users must remap CNTRL-A&lt;br /&gt;
&amp;lt;C-R&amp;gt;=5*5                       : insert 25 into text (mini-calculator)&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Make all other tips superfluous&lt;br /&gt;
:h 42            : also http://www.google.com/search?q=42&lt;br /&gt;
:h holy-grail&lt;br /&gt;
:h!&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; disguise text (watch out) [N]&lt;br /&gt;
ggVGg?                          : rot13 whole file (toggles)&lt;br /&gt;
:set rl!                        : reverse lines right to left (toggles)&lt;br /&gt;
:g/^/m0                         : reverse lines top to bottom (toggles)&lt;br /&gt;
:%s/\(\&amp;lt;.\{-}\&amp;gt;\)/\=join(reverse(split(submatch(1), '.\zs')), '')/g   : reverse all text *N*&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; History, Markers &amp;amp; moving about (what Vim Remembers) [C]&lt;br /&gt;
'.               : jump to last modification line (SUPER)&lt;br /&gt;
`.               : jump to exact spot in last modification line&lt;br /&gt;
g;               : cycle thru recent changes (oldest first)&lt;br /&gt;
g,               : reverse direction &lt;br /&gt;
:changes&lt;br /&gt;
:h changelist    : help for above&lt;br /&gt;
&amp;lt;C-O&amp;gt;            : retrace your movements in file (starting from most recent)&lt;br /&gt;
&amp;lt;C-I&amp;gt;            : retrace your movements in file (reverse direction)&lt;br /&gt;
:ju(mps)         : list of your movements&lt;br /&gt;
:help jump-motions&lt;br /&gt;
:history         : list of all your commands&lt;br /&gt;
:his c           : commandline history&lt;br /&gt;
:his s           : search history&lt;br /&gt;
q/               : Search history Window (puts you in full edit mode) (exit CTRL-C)&lt;br /&gt;
q:               : commandline history Window (puts you in full edit mode) (exit CTRL-C)&lt;br /&gt;
:&amp;lt;C-F&amp;gt;           : history Window (exit CTRL-C)&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Abbreviations &amp;amp; Maps&lt;br /&gt;
&amp;quot; Maps are commands put onto keys, abbreviations expand typed text [N]&lt;br /&gt;
&amp;quot; Following 4 maps enable text transfer between VIM sessions&lt;br /&gt;
:map   &amp;lt;f7&amp;gt;   :'a,'bw! c:/aaa/x       : save text to file x&lt;br /&gt;
:map   &amp;lt;f8&amp;gt;   :r c:/aaa/x             : retrieve text &lt;br /&gt;
:map   &amp;lt;f11&amp;gt;  :.w! c:/aaa/xr&amp;lt;CR&amp;gt;      : store current line&lt;br /&gt;
:map   &amp;lt;f12&amp;gt;  :r c:/aaa/xr&amp;lt;CR&amp;gt;        : retrieve current line&lt;br /&gt;
:ab php          : list of abbreviations beginning php&lt;br /&gt;
:map ,           : list of maps beginning ,&lt;br /&gt;
&amp;quot; allow use of F10 for mapping (win32)&lt;br /&gt;
set wak=no       : :h winaltkeys&lt;br /&gt;
&amp;quot; For use in Maps&lt;br /&gt;
&amp;lt;CR&amp;gt;             : carriage Return for maps&lt;br /&gt;
&amp;lt;ESC&amp;gt;            : Escape&lt;br /&gt;
&amp;lt;LEADER&amp;gt;         : normally \&lt;br /&gt;
&amp;lt;BAR&amp;gt;            : | pipe&lt;br /&gt;
&amp;lt;BACKSPACE&amp;gt;      : backspace&lt;br /&gt;
&amp;lt;SILENT&amp;gt;         : No hanging shell window&lt;br /&gt;
&amp;quot;display RGB colour under the cursor eg #445588&lt;br /&gt;
:nmap &amp;lt;leader&amp;gt;c :hi Normal guibg=#&amp;lt;c-r&amp;gt;=expand(&amp;quot;&amp;lt;cword&amp;gt;&amp;quot;)&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;&lt;br /&gt;
map &amp;lt;f2&amp;gt; /price only\\|versus/ :in a map need to backslash the \&lt;br /&gt;
&amp;quot; type table,,, to get &amp;lt;table&amp;gt;&amp;lt;/table&amp;gt;       ### Cool ###&lt;br /&gt;
imap ,,, &amp;lt;esc&amp;gt;bdwa&amp;lt;&amp;lt;esc&amp;gt;pa&amp;gt;&amp;lt;cr&amp;gt;&amp;lt;/&amp;lt;esc&amp;gt;pa&amp;gt;&amp;lt;esc&amp;gt;kA&lt;br /&gt;
&amp;quot; list current mappings of all your function keys&lt;br /&gt;
:for i in range(1, 12) | execute(&amp;quot;map &amp;lt;F&amp;quot;.i.&amp;quot;&amp;gt;&amp;quot;) | endfor   [N]&lt;br /&gt;
&amp;quot; for your .vimrc&lt;br /&gt;
:cab ,f :for i in range(1, 12) \| execute(&amp;quot;map &amp;lt;F&amp;quot;.i.&amp;quot;&amp;gt;&amp;quot;) \| endfor&lt;br /&gt;
&amp;quot;chain commands in abbreviation&lt;br /&gt;
cabbrev vrep tabe class.inc \| tabe report.php   ## chain commands [N]&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Simple PHP debugging display all variables yanked into register a&lt;br /&gt;
iab phpdb exit(&amp;quot;&amp;lt;hr&amp;gt;Debug &amp;lt;C-R&amp;gt;a  &amp;quot;);&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Using a register as a map (preload registers in .vimrc)&lt;br /&gt;
:let @m=&amp;quot;:'a,'bs/&amp;quot;&lt;br /&gt;
:let @s=&amp;quot;:%!sort -u&amp;quot;&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Useful tricks&lt;br /&gt;
&amp;quot;ayy@a           : execute &amp;quot;Vim command&amp;quot; in a text file&lt;br /&gt;
yy@&amp;quot;             : same thing using unnamed register&lt;br /&gt;
u@.              : execute command JUST typed in&lt;br /&gt;
&amp;quot;ddw             : store what you delete in register d [N]&lt;br /&gt;
&amp;quot;ccaw            : store what you change in register c [N]&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Get output from other commands (requires external programs)&lt;br /&gt;
:r!ls -R         : reads in output of ls&lt;br /&gt;
:put=glob('**')  : same as above                 [N]&lt;br /&gt;
:r !grep &amp;quot;^ebay&amp;quot; file.txt  : grepping in content   [N]&lt;br /&gt;
:20,25 !rot13    : rot13 lines 20 to 25   [N]&lt;br /&gt;
!!date           : same thing (but replaces/filters current line)&lt;br /&gt;
&amp;quot; Sorting with external sort&lt;br /&gt;
:%!sort -u       : use an external program to filter content&lt;br /&gt;
:'a,'b!sort -u   : use an external program to filter content&lt;br /&gt;
!1} sort -u      : sorts paragraph (note normal mode!!)&lt;br /&gt;
:g/^$/;/^$/-1!sort : Sort each block (note the crucial ;)&lt;br /&gt;
&amp;quot; Sorting with internal sort&lt;br /&gt;
:sort /.*\%2v/   : sort all lines on second column [N]&lt;br /&gt;
&amp;quot; number lines  (linux or cygwin only)&lt;br /&gt;
:new | r!nl #                  [N]&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Multiple Files Management (Essential)&lt;br /&gt;
:bn              : goto next buffer&lt;br /&gt;
:bp              : goto previous buffer&lt;br /&gt;
:wn              : save file and move to next (super)&lt;br /&gt;
:wp              : save file and move to previous&lt;br /&gt;
:bd              : remove file from buffer list (super)&lt;br /&gt;
:bun             : Buffer unload (remove window but not from list)&lt;br /&gt;
:badd file.c     : file from buffer list&lt;br /&gt;
:b3              : go to buffer 3 [C]&lt;br /&gt;
:b main          : go to buffer with main in name eg main.c (ultra)&lt;br /&gt;
:sav php.html    : Save current file as php.html and &amp;quot;move&amp;quot; to php.html&lt;br /&gt;
:sav! %&amp;lt;.bak     : Save Current file to alternative extension (old way)&lt;br /&gt;
:sav! %:r.cfm    : Save Current file to alternative extension&lt;br /&gt;
:sav %:s/fred/joe/           : do a substitute on file name&lt;br /&gt;
:sav %:s/fred/joe/:r.bak2    : do a substitute on file name &amp;amp; ext.&lt;br /&gt;
:!mv % %:r.bak   : rename current file (DOS use Rename or DEL)&lt;br /&gt;
:help filename-modifiers&lt;br /&gt;
:e!              : return to unmodified file&lt;br /&gt;
:w c:/aaa/%      : save file elsewhere&lt;br /&gt;
:e #             : edit alternative file (also cntrl-^)&lt;br /&gt;
:rew             : return to beginning of edited files list (:args)&lt;br /&gt;
:brew            : buffer rewind&lt;br /&gt;
:sp fred.txt     : open fred.txt into a split&lt;br /&gt;
:sball,:sb       : Split all buffers (super)&lt;br /&gt;
:scrollbind      : in each split window&lt;br /&gt;
:map   &amp;lt;F5&amp;gt; :ls&amp;lt;CR&amp;gt;:e # : Pressing F5 lists all buffer, just type number&lt;br /&gt;
:set hidden      : Allows to change buffer w/o saving current buffer&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Quick jumping between splits&lt;br /&gt;
map &amp;lt;C-J&amp;gt; &amp;lt;C-W&amp;gt;j&amp;lt;C-W&amp;gt;_&lt;br /&gt;
map &amp;lt;C-K&amp;gt; &amp;lt;C-W&amp;gt;k&amp;lt;C-W&amp;gt;_&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Recording (BEST Feature of ALL)&lt;br /&gt;
qq  # record to q&lt;br /&gt;
your complex series of commands&lt;br /&gt;
q   # end recording&lt;br /&gt;
@q to execute&lt;br /&gt;
@@ to Repeat&lt;br /&gt;
5@@ to Repeat 5 times&lt;br /&gt;
qQ@qq                             : Make an existing recording q recursive [N]&lt;br /&gt;
&amp;quot; editing a register/recording&lt;br /&gt;
&amp;quot;qp                               :display contents of register q (normal mode)&lt;br /&gt;
&amp;lt;ctrl-R&amp;gt;q                         :display contents of register q (insert mode)&lt;br /&gt;
&amp;quot; you can now see recording contents, edit as required&lt;br /&gt;
&amp;quot;qdd                              :put changed contacts back into q&lt;br /&gt;
@q                                :execute recording/register q&lt;br /&gt;
&amp;quot; Operating a Recording on a Visual BLOCK (blockwise)&lt;br /&gt;
1) define recording/register&lt;br /&gt;
qq:s/ to/ from/g^Mq&lt;br /&gt;
2) Define Visual BLOCK&lt;br /&gt;
V}&lt;br /&gt;
3) hit : and the following appears&lt;br /&gt;
:'&amp;lt;,'&amp;gt;&lt;br /&gt;
4)Complete as follows&lt;br /&gt;
:'&amp;lt;,'&amp;gt;norm @q&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot;combining a recording with a map (to end up in command mode)&lt;br /&gt;
&amp;quot;here we operate on a file with a recording, then move to the next file [N]&lt;br /&gt;
:nnoremap ] @q:update&amp;lt;bar&amp;gt;bd&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Visual is the newest and usually the most intuitive editing mode&lt;br /&gt;
&amp;quot; Visual basics&lt;br /&gt;
v                               : enter visual mode&lt;br /&gt;
V                               : visual mode whole line&lt;br /&gt;
&amp;lt;C-V&amp;gt;                           : enter VISUAL BLOCKWISE mode (remap on Windows to say C-Q *C*&lt;br /&gt;
gv                              : reselect last visual area (ultra)&lt;br /&gt;
o                               : navigate visual area&lt;br /&gt;
&amp;quot;*y or &amp;quot;+y                      : yank visual area into paste buffer  [C]&lt;br /&gt;
V%                              : visualise what you match&lt;br /&gt;
V}J                             : Join Visual block (great)&lt;br /&gt;
V}gJ                            : Join Visual block w/o adding spaces&lt;br /&gt;
`[v`]                           : Highlight last insert&lt;br /&gt;
:%s/\%Vold/new/g                : Do a substitute on last visual area [N]&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Delete 8th and 9th characters of 10 successive lines [C]&lt;br /&gt;
08l&amp;lt;c-v&amp;gt;10j2ld  (use Control Q on win32) [C]&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; how to copy a set of columns using VISUAL BLOCK&lt;br /&gt;
&amp;quot; visual block (AKA columnwise selection) (NOT BY ordinary v command)&lt;br /&gt;
&amp;lt;C-V&amp;gt; then select &amp;quot;column(s)&amp;quot; with motion commands (win32 &amp;lt;C-Q&amp;gt;)&lt;br /&gt;
then c,d,y,r etc&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; how to overwrite a visual-block of text with another such block [C]&lt;br /&gt;
&amp;quot; move with hjkl etc&lt;br /&gt;
Pick the first block: ctrl-v move y&lt;br /&gt;
Pick the second block: ctrl-v move P &amp;lt;esc&amp;gt;&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; text objects :h text-objects                                     [C]&lt;br /&gt;
daW                                   : delete contiguous non whitespace&lt;br /&gt;
di&amp;lt;   yi&amp;lt;  ci&amp;lt;                        : Delete/Yank/Change HTML tag contents&lt;br /&gt;
da&amp;lt;   ya&amp;lt;  ca&amp;lt;                        : Delete/Yank/Change whole HTML tag&lt;br /&gt;
dat   dit                             : Delete HTML tag pair&lt;br /&gt;
diB   daB                             : Empty a function {}&lt;br /&gt;
das                                   : delete a sentence&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; _vimrc essentials&lt;br /&gt;
:imap &amp;lt;TAB&amp;gt; &amp;lt;C-N&amp;gt;                     : set tab to complete [N]&lt;br /&gt;
:set incsearch : jumps to search word as you type (annoying but excellent)&lt;br /&gt;
:set wildignore=*.o,*.obj,*.bak,*.exe : tab complete now ignores these&lt;br /&gt;
:set shiftwidth=3                     : for shift/tabbing&lt;br /&gt;
:set vb t_vb=&amp;quot;.                       : set silent (no beep)&lt;br /&gt;
:set browsedir=buffer                 : Maki GUI File Open use current directory&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; launching Win IE&lt;br /&gt;
:nmap ,f :update&amp;lt;CR&amp;gt;:silent !start c:\progra~1\intern~1\iexplore.exe file://%:p&amp;lt;CR&amp;gt;&lt;br /&gt;
:nmap ,i :update&amp;lt;CR&amp;gt;: !start c:\progra~1\intern~1\iexplore.exe &amp;lt;cWORD&amp;gt;&amp;lt;CR&amp;gt;&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; FTPing from VIM&lt;br /&gt;
cmap ,r  :Nread ftp://209.51.134.122/public_html/index.html&lt;br /&gt;
cmap ,w  :Nwrite ftp://209.51.134.122/public_html/index.html&lt;br /&gt;
gvim ftp://www.somedomain.com/index.html # uses netrw.vim&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; appending to registers (use CAPITAL)&lt;br /&gt;
&amp;quot; yank 5 lines into &amp;quot;a&amp;quot; then add a further 5&lt;br /&gt;
&amp;quot;a5yy&lt;br /&gt;
10j&lt;br /&gt;
&amp;quot;A5yy&lt;br /&gt;
----------------------------------------&lt;br /&gt;
[I     : show lines matching word under cursor &amp;lt;cword&amp;gt; (super)&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Conventional Shifting/Indenting&lt;br /&gt;
:'a,'b&amp;gt;&amp;gt;&lt;br /&gt;
&amp;quot; visual shifting (builtin-repeat)&lt;br /&gt;
:vnoremap &amp;lt; &amp;lt;gv&lt;br /&gt;
:vnoremap &amp;gt; &amp;gt;gv&lt;br /&gt;
&amp;quot; Block shifting (magic)&lt;br /&gt;
&amp;gt;i{&lt;br /&gt;
&amp;gt;a{&lt;br /&gt;
&amp;quot; also&lt;br /&gt;
&amp;gt;% and &amp;lt;%&lt;br /&gt;
==                            : index current line same as line above [N]&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Redirection &amp;amp; Paste register *&lt;br /&gt;
:redir @*                    : redirect commands to paste buffer&lt;br /&gt;
:redir END                   : end redirect&lt;br /&gt;
:redir &amp;gt;&amp;gt; out.txt            : redirect to a file&lt;br /&gt;
&amp;quot; Working with Paste buffer&lt;br /&gt;
&amp;quot;*yy                         : yank curent line to paste&lt;br /&gt;
&amp;quot;*p                          : insert from paste buffer&lt;br /&gt;
&amp;quot; yank to paste buffer (ex mode)&lt;br /&gt;
:'a,'by*                     : Yank range into paste&lt;br /&gt;
:%y*                         : Yank whole buffer into paste&lt;br /&gt;
:.y*                         : Yank Current line to paster&lt;br /&gt;
&amp;quot; filter non-printable characters from the paste buffer&lt;br /&gt;
&amp;quot; useful when pasting from some gui application&lt;br /&gt;
:nmap &amp;lt;leader&amp;gt;p :let @* = substitute(@*,'[^[:print:]]','','g')&amp;lt;cr&amp;gt;&amp;quot;*p&lt;br /&gt;
:set paste                    : prevent vim from formatting pasted in text *N*&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Re-Formatting text&lt;br /&gt;
gq}                          : Format a paragraph&lt;br /&gt;
gqap                         : Format a paragraph&lt;br /&gt;
ggVGgq                       : Reformat entire file&lt;br /&gt;
Vgq                          : current line&lt;br /&gt;
&amp;quot; break lines at 70 chars, if possible after a ;&lt;br /&gt;
:s/.\{,69\};\s*\|.\{,69\}\s\+/&amp;amp;\r/g&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Operate command over multiple files&lt;br /&gt;
:argdo %s/foo/bar/e          : operate on all files in :args&lt;br /&gt;
:bufdo %s/foo/bar/e&lt;br /&gt;
:windo %s/foo/bar/e&lt;br /&gt;
:argdo exe '%!sort'|w!       : include an external command&lt;br /&gt;
:bufdo exe &amp;quot;normal @q&amp;quot; | w   : perform a recording on open files&lt;br /&gt;
:silent bufdo !zip proj.zip %:p   : zip all current files&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Command line tricks&lt;br /&gt;
gvim -h                    : help&lt;br /&gt;
ls | gvim -                : edit a stream!!&lt;br /&gt;
cat xx | gvim - -c &amp;quot;v/^\d\d\|^[3-9]/d &amp;quot; : filter a stream&lt;br /&gt;
gvim -o file1 file2        : open into a horizontal split (file1 on top, file2 on bottom) [C]&lt;br /&gt;
gvim -O file1 file2        : open into a vertical split (side by side,for comparing code) [N]&lt;br /&gt;
&amp;quot; execute one command after opening file&lt;br /&gt;
gvim.exe -c &amp;quot;/main&amp;quot; joe.c  : Open joe.c &amp;amp; jump to &amp;quot;main&amp;quot;&lt;br /&gt;
&amp;quot; execute multiple command on a single file&lt;br /&gt;
vim -c &amp;quot;%s/ABC/DEF/ge | update&amp;quot; file1.c&lt;br /&gt;
&amp;quot; execute multiple command on a group of files&lt;br /&gt;
vim -c &amp;quot;argdo %s/ABC/DEF/ge | update&amp;quot; *.c&lt;br /&gt;
&amp;quot; remove blocks of text from a series of files&lt;br /&gt;
vim -c &amp;quot;argdo /begin/+1,/end/-1g/^/d | update&amp;quot; *.c&lt;br /&gt;
&amp;quot; Automate editing of a file (Ex commands in convert.vim)&lt;br /&gt;
vim -s &amp;quot;convert.vim&amp;quot; file.c&lt;br /&gt;
&amp;quot;load VIM without .vimrc and plugins (clean VIM) e.g. for HUGE files&lt;br /&gt;
gvim -u NONE -U NONE -N&lt;br /&gt;
&amp;quot; Access paste buffer contents (put in a script/batch file)&lt;br /&gt;
gvim -c 'normal ggdG&amp;quot;*p' c:/aaa/xp&lt;br /&gt;
&amp;quot; print paste contents to default printer&lt;br /&gt;
gvim -c 's/^/\=@*/|hardcopy!|q!'&lt;br /&gt;
&amp;quot; gvim's use of external grep (win32 or *nix)&lt;br /&gt;
:!grep somestring *.php     : creates a list of all matching files [C]&lt;br /&gt;
&amp;quot; use :cn(ext) :cp(rev) to navigate list&lt;br /&gt;
:h grep&lt;br /&gt;
&amp;quot; Using vimgrep with copen                              [N]&lt;br /&gt;
:vimgrep /keywords/ *.php&lt;br /&gt;
:copen&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; GVIM Difference Function (Brilliant)&lt;br /&gt;
gvim -d file1 file2        : vimdiff (compare differences)&lt;br /&gt;
dp                         : &amp;quot;put&amp;quot; difference under cursor to other file&lt;br /&gt;
do                         : &amp;quot;get&amp;quot; difference under cursor from other file&lt;br /&gt;
&amp;quot; complex diff parts of same file [N]&lt;br /&gt;
:1,2yank a | 7,8yank b&lt;br /&gt;
:tabedit | put a | vnew | put b&lt;br /&gt;
:windo diffthis &lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Vim traps&lt;br /&gt;
In regular expressions you must backslash + (match 1 or more)&lt;br /&gt;
In regular expressions you must backslash | (or)&lt;br /&gt;
In regular expressions you must backslash ( (group)&lt;br /&gt;
In regular expressions you must backslash { (count)&lt;br /&gt;
/fred\+/                   : matches fred/freddy but not free&lt;br /&gt;
/\(fred\)\{2,3}/           : note what you have to break&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; \v or very magic (usually) reduces backslashing&lt;br /&gt;
/codes\(\n\|\s\)*where  : normal regexp&lt;br /&gt;
/\vcodes(\n|\s)*where   : very magic&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; pulling objects onto command/search line (SUPER)&lt;br /&gt;
&amp;lt;C-R&amp;gt;&amp;lt;C-W&amp;gt; : pull word under the cursor into a command line or search&lt;br /&gt;
&amp;lt;C-R&amp;gt;&amp;lt;C-A&amp;gt; : pull WORD under the cursor into a command line or search&lt;br /&gt;
&amp;lt;C-R&amp;gt;-                  : pull small register (also insert mode)&lt;br /&gt;
&amp;lt;C-R&amp;gt;[0-9a-z]           : pull named registers (also insert mode)&lt;br /&gt;
&amp;lt;C-R&amp;gt;%                  : pull file name (also #) (also insert mode)&lt;br /&gt;
&amp;lt;C-R&amp;gt;=somevar           : pull contents of a variable (eg :let sray=&amp;quot;ray[0-9]&amp;quot;)&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; List your Registers&lt;br /&gt;
:reg             : display contents of all registers&lt;br /&gt;
:reg a           : display content of register a&lt;br /&gt;
:reg 12a         : display content of registers 1,2 &amp;amp; a [N]&lt;br /&gt;
&amp;quot;5p              : retrieve 5th &amp;quot;ring&amp;quot; &lt;br /&gt;
&amp;quot;1p....          : retrieve numeric registers one by one&lt;br /&gt;
:let @y='yy@&amp;quot;'   : pre-loading registers (put in .vimrc)&lt;br /&gt;
qqq              : empty register &amp;quot;q&amp;quot;&lt;br /&gt;
qaq              : empty register &amp;quot;a&amp;quot;&lt;br /&gt;
:reg .-/%:*&amp;quot;     : the seven special registers [N]&lt;br /&gt;
:reg 0           : what you last yanked, not affected by a delete [N]&lt;br /&gt;
&amp;quot;_dd             : Delete to blackhole register &amp;quot;_ , don't affect any register [N]&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; manipulating registers&lt;br /&gt;
:let @a=@_              : clear register a&lt;br /&gt;
:let @a=&amp;quot;&amp;quot;              : clear register a&lt;br /&gt;
:let @a=@&amp;quot;              : Save unnamed register [N]&lt;br /&gt;
:let @*=@a              : copy register a to paste buffer&lt;br /&gt;
:let @*=@:              : copy last command to paste buffer&lt;br /&gt;
:let @*=@/              : copy last search to paste buffer&lt;br /&gt;
:let @*=@%              : copy current filename to paste buffer&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; help for help (USE TAB)&lt;br /&gt;
:h quickref             : VIM Quick Reference Sheet (ultra)&lt;br /&gt;
:h tips                 : Vim's own Tips Help&lt;br /&gt;
:h visual&amp;lt;C-D&amp;gt;&amp;lt;tab&amp;gt;     : obtain  list of all visual help topics&lt;br /&gt;
                        : Then use tab to step thru them&lt;br /&gt;
:h ctrl&amp;lt;C-D&amp;gt;            : list help of all control keys&lt;br /&gt;
:helpg uganda           : grep HELP Files use :cn, :cp to find next&lt;br /&gt;
:helpgrep edit.*director: grep help using regexp&lt;br /&gt;
:h :r                   : help for :ex command&lt;br /&gt;
:h CTRL-R               : normal mode&lt;br /&gt;
:h /\r                  : what's \r in a regexp (matches a &amp;lt;CR&amp;gt;)&lt;br /&gt;
:h \\zs                 : double up backslash to find \zs in help&lt;br /&gt;
:h i_CTRL-R             : help for say &amp;lt;C-R&amp;gt; in insert mode&lt;br /&gt;
:h c_CTRL-R             : help for say &amp;lt;C-R&amp;gt; in command mode&lt;br /&gt;
:h v_CTRL-V             : visual mode&lt;br /&gt;
:h tutor                : VIM Tutor&lt;br /&gt;
&amp;lt;C-]&amp;gt;                   : jump to {keyword} under  cursor in help file [C]&lt;br /&gt;
&amp;lt;C-[&amp;gt;, &amp;lt;C-T&amp;gt;            : Move back &amp;amp; Forth in HELP History&lt;br /&gt;
gvim -h                 : VIM Command Line Help&lt;br /&gt;
:cabbrev h tab help     : open help in a tab [N]&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; where was an option set&lt;br /&gt;
:scriptnames            : list all plugins, _vimrcs loaded (super)&lt;br /&gt;
:verbose set history?   : reveals value of history and where set&lt;br /&gt;
:function               : list functions&lt;br /&gt;
:func SearchCompl       : List particular function&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; making your own VIM help&lt;br /&gt;
:helptags /vim/vim64/doc  : rebuild all *.txt help files in /doc&lt;br /&gt;
:help add-local-help&lt;br /&gt;
&amp;quot; save this page as a VIM Help File [N]&lt;br /&gt;
:sav! $VIMRUNTIME/doc/vimtips.txt|:1,/^__BEGIN__/d|:/^__END__/,$d|:w!|:helptags $VIMRUNTIME/doc&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; running file thru an external program (eg php)&lt;br /&gt;
map   &amp;lt;f9&amp;gt;   :w&amp;lt;CR&amp;gt;:!c:/php/php.exe %&amp;lt;CR&amp;gt;&lt;br /&gt;
map   &amp;lt;f2&amp;gt;   :w&amp;lt;CR&amp;gt;:!perl -c %&amp;lt;CR&amp;gt;&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; capturing output of current script in a separate buffer&lt;br /&gt;
:new | r!perl #                   : opens new buffer,read other buffer&lt;br /&gt;
:new! x.out | r!perl #            : same with named file&lt;br /&gt;
:new+read!ls&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; create a new buffer, paste a register &amp;quot;q&amp;quot; into it, then sort new buffer&lt;br /&gt;
:new +put q|%!sort&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Inserting DOS Carriage Returns&lt;br /&gt;
:%s/$/\&amp;lt;C-V&amp;gt;&amp;lt;C-M&amp;gt;&amp;amp;/g          :  that's what you type&lt;br /&gt;
:%s/$/\&amp;lt;C-Q&amp;gt;&amp;lt;C-M&amp;gt;&amp;amp;/g          :  for Win32&lt;br /&gt;
:%s/$/\^M&amp;amp;/g                  :  what you'll see where ^M is ONE character&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; automatically delete trailing Dos-returns,whitespace&lt;br /&gt;
autocmd BufRead * silent! %s/[\r \t]\+$//&lt;br /&gt;
autocmd BufEnter *.php :%s/[ \t\r]\+$//e&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; perform an action on a particular file or file type&lt;br /&gt;
autocmd VimEnter c:/intranet/note011.txt normal! ggVGg?&lt;br /&gt;
autocmd FileType *.pl exec('set fileformats=unix')&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Retrieving last command line command for copy &amp;amp; pasting into text&lt;br /&gt;
i&amp;lt;c-r&amp;gt;:&lt;br /&gt;
&amp;quot; Retrieving last Search Command for copy &amp;amp; pasting into text&lt;br /&gt;
i&amp;lt;c-r&amp;gt;/&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; more completions&lt;br /&gt;
&amp;lt;C-X&amp;gt;&amp;lt;C-F&amp;gt;                        :insert name of a file in current directory&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Substituting a Visual area&lt;br /&gt;
&amp;quot; select visual area as usual (:h visual) then type :s/Emacs/Vim/ etc&lt;br /&gt;
:'&amp;lt;,'&amp;gt;s/Emacs/Vim/g               : REMEMBER you dont type the '&amp;lt;.'&amp;gt;&lt;br /&gt;
gv                                : Re-select the previous visual area (ULTRA)&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; inserting line number into file&lt;br /&gt;
:g/^/exec &amp;quot;s/^/&amp;quot;.strpart(line(&amp;quot;.&amp;quot;).&amp;quot;    &amp;quot;, 0, 4)&lt;br /&gt;
:%s/^/\=strpart(line(&amp;quot;.&amp;quot;).&amp;quot;     &amp;quot;, 0, 5)&lt;br /&gt;
:%s/^/\=line('.'). ' '&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; *numbering lines VIM way*&lt;br /&gt;
:set number                       : show line numbers&lt;br /&gt;
:map &amp;lt;F12&amp;gt; :set number!&amp;lt;CR&amp;gt;       : Show linenumbers flip-flop&lt;br /&gt;
:%s/^/\=strpart(line('.').&amp;quot;        &amp;quot;,0,&amp;amp;ts)&lt;br /&gt;
&amp;quot; numbering lines (need Perl on PC) starting from arbitrary number&lt;br /&gt;
:'a,'b!perl -pne 'BEGIN{$a=223} substr($_,2,0)=$a++'&lt;br /&gt;
&amp;quot; Produce a list of numbers&lt;br /&gt;
&amp;quot; Type in number on line say 223 in an empty file&lt;br /&gt;
qqmnYP`n^Aq                       : in recording q repeat with @q&lt;br /&gt;
&amp;quot; increment existing numbers to end of file (type &amp;lt;c-a&amp;gt; as 5 characters)&lt;br /&gt;
:.,$g/^\d/exe &amp;quot;normal! \&amp;lt;c-a&amp;gt;&amp;quot;&lt;br /&gt;
&amp;quot; advanced incrementing&lt;br /&gt;
http://vim.sourceforge.net/tip_view.php?tip_id=150&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; *advanced incrementing* (really useful)&lt;br /&gt;
&amp;quot; put following in _vimrc&lt;br /&gt;
let g:I=0&lt;br /&gt;
function! INC(increment)&lt;br /&gt;
let g:I =g:I + a:increment&lt;br /&gt;
return g:I&lt;br /&gt;
endfunction&lt;br /&gt;
&amp;quot; eg create list starting from 223 incrementing by 5 between markers a,b&lt;br /&gt;
:let I=223&lt;br /&gt;
:'a,'bs/^/\=INC(5)/&lt;br /&gt;
&amp;quot; create a map for INC&lt;br /&gt;
cab viminc :let I=223 \| 'a,'bs/$/\=INC(5)/&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; *generate a list of numbers*  23-64&lt;br /&gt;
o23&amp;lt;ESC&amp;gt;qqYp&amp;lt;C-A&amp;gt;q40@q&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; editing/moving within current insert (Really useful)&lt;br /&gt;
&amp;lt;C-U&amp;gt;                             : delete all entered&lt;br /&gt;
&amp;lt;C-W&amp;gt;                             : delete last word&lt;br /&gt;
&amp;lt;HOME&amp;gt;&amp;lt;END&amp;gt;                       : beginning/end of line&lt;br /&gt;
&amp;lt;C-LEFTARROW&amp;gt;&amp;lt;C-RIGHTARROW&amp;gt;       : jump one word backwards/forwards&lt;br /&gt;
&amp;lt;C-X&amp;gt;&amp;lt;C-E&amp;gt;,&amp;lt;C-X&amp;gt;&amp;lt;C-Y&amp;gt;             : scroll while staying put in insert&lt;br /&gt;
----------------------------------------&lt;br /&gt;
#encryption (use with care: DON'T FORGET your KEY)&lt;br /&gt;
:X                                : you will be prompted for a key&lt;br /&gt;
:h :X&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; modeline (make a file readonly etc) must be in first/last 5 lines&lt;br /&gt;
// vim:noai:ts=2:sw=4:readonly:&lt;br /&gt;
&amp;quot; vim:ft=html:                    : says use HTML Syntax highlighting&lt;br /&gt;
:h modeline&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Creating your own GUI Toolbar entry&lt;br /&gt;
amenu  Modeline.Insert\ a\ VIM\ modeline &amp;lt;Esc&amp;gt;&amp;lt;Esc&amp;gt;ggOvim:ff=unix ts=4 ss=4&amp;lt;CR&amp;gt;vim60:fdm=marker&amp;lt;esc&amp;gt;gg&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; A function to save word under cursor to a file&lt;br /&gt;
function! SaveWord()&lt;br /&gt;
   normal yiw&lt;br /&gt;
   exe ':!echo '.@0.' &amp;gt;&amp;gt; word.txt'&lt;br /&gt;
endfunction&lt;br /&gt;
map ,p :call SaveWord()&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; function to delete duplicate lines&lt;br /&gt;
function! Del()&lt;br /&gt;
 if getline(&amp;quot;.&amp;quot;) == getline(line(&amp;quot;.&amp;quot;) - 1)&lt;br /&gt;
   norm dd&lt;br /&gt;
 endif&lt;br /&gt;
endfunction&lt;br /&gt;
&lt;br /&gt;
:g/^/ call Del()&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Digraphs (non alpha-numerics)&lt;br /&gt;
:digraphs                         : display table&lt;br /&gt;
:h dig                            : help&lt;br /&gt;
i&amp;lt;C-K&amp;gt;e'                          : enters é&lt;br /&gt;
i&amp;lt;C-V&amp;gt;233                         : enters é (Unix)&lt;br /&gt;
i&amp;lt;C-Q&amp;gt;233                         : enters é (Win32)&lt;br /&gt;
ga                                : View hex value of any character&lt;br /&gt;
#Deleting non-ascii characters (some invisible)&lt;br /&gt;
:%s/[\x00-\x1f\x80-\xff]/ /g      : type this as you see it&lt;br /&gt;
:%s/[&amp;lt;C-V&amp;gt;128-&amp;lt;C-V&amp;gt;255]//gi       : where you have to type the Control-V&lt;br /&gt;
:%s/[€-ÿ]//gi                     : Should see a black square &amp;amp; a dotted y&lt;br /&gt;
:%s/[&amp;lt;C-V&amp;gt;128-&amp;lt;C-V&amp;gt;255&amp;lt;C-V&amp;gt;01-&amp;lt;C-V&amp;gt;31]//gi : All pesky non-asciis&lt;br /&gt;
:exec &amp;quot;norm /[\x00-\x1f\x80-\xff]/&amp;quot;        : same thing&lt;br /&gt;
#Pull a non-ascii character onto search bar&lt;br /&gt;
yl/&amp;lt;C-R&amp;gt;&amp;quot;                         :&lt;br /&gt;
/[^a-zA-Z0-9_[:space:][:punct:]]  : search for all non-ascii&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; All file completions grouped (for example main_c.c)&lt;br /&gt;
:e main_&amp;lt;tab&amp;gt;                     : tab completes&lt;br /&gt;
gf                                : open file under cursor  (normal)&lt;br /&gt;
main_&amp;lt;C-X&amp;gt;&amp;lt;C-F&amp;gt;                   : include NAME of file in text (insert mode)&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Complex Vim&lt;br /&gt;
&amp;quot; swap two words&lt;br /&gt;
:%s/\&amp;lt;\(on\|off\)\&amp;gt;/\=strpart(&amp;quot;offon&amp;quot;, 3 * (&amp;quot;off&amp;quot; == submatch(0)), 3)/g&lt;br /&gt;
&amp;quot; swap two words&lt;br /&gt;
:vnoremap &amp;lt;C-X&amp;gt; &amp;lt;Esc&amp;gt;`.``gvP``P&lt;br /&gt;
&amp;quot; Swap word with next word&lt;br /&gt;
nmap &amp;lt;silent&amp;gt; gw    &amp;quot;_yiw:s/\(\%#\w\+\)\(\_W\+\)\(\w\+\)/\3\2\1/&amp;lt;cr&amp;gt;&amp;lt;c-o&amp;gt;&amp;lt;c-l&amp;gt; [N]&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Convert Text File to HTML&lt;br /&gt;
:runtime! syntax/2html.vim        : convert txt to html&lt;br /&gt;
:h 2html&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; VIM has internal grep&lt;br /&gt;
:grep some_keyword *.c            : get list of all c-files containing keyword&lt;br /&gt;
:cn                               : go to next occurrence&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Force Syntax coloring for a file that has no extension .pl&lt;br /&gt;
:set syntax=perl&lt;br /&gt;
&amp;quot; Remove syntax coloring (useful for all sorts of reasons)&lt;br /&gt;
:set syntax off&lt;br /&gt;
&amp;quot; change coloring scheme (any file in ~vim/vim??/colors)&lt;br /&gt;
:colorscheme blue&lt;br /&gt;
:colorscheme morning     : good fallback colorscheme *N*&lt;br /&gt;
&amp;quot; Force HTML Syntax highlighting by using a modeline&lt;br /&gt;
# vim:ft=html:&lt;br /&gt;
&amp;quot; Force syntax automatically (for a file with non-standard extension)&lt;br /&gt;
au BufRead,BufNewFile */Content.IE?/* setfiletype html&lt;br /&gt;
----------------------------------------&lt;br /&gt;
:set noma (non modifiable)        : Prevents modifications&lt;br /&gt;
:set ro (Read Only)               : Protect a file from unintentional writes&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Sessions (Open a set of files)&lt;br /&gt;
gvim file1.c file2.c lib/lib.h lib/lib2.h : load files for &amp;quot;session&amp;quot;&lt;br /&gt;
:mksession                        : Make a Session file (default Session.vim)&lt;br /&gt;
:mksession MySession.vim          : Make a Session file named file [C]&lt;br /&gt;
:q&lt;br /&gt;
gvim -S                           : Reload all files (loads Session.vim) [C]&lt;br /&gt;
gvim -S MySession.vim             : Reload all files from named session [C]&lt;br /&gt;
----------------------------------------&lt;br /&gt;
#tags (jumping to subroutines/functions)&lt;br /&gt;
taglist.vim                       : popular plugin&lt;br /&gt;
:Tlist                            : display Tags (list of functions)&lt;br /&gt;
&amp;lt;C-]&amp;gt;                             : jump to function under cursor&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; columnise a csv file for display only as may crop wide columns&lt;br /&gt;
:let width = 20&lt;br /&gt;
:let fill=' ' | while strlen(fill) &amp;lt; width | let fill=fill.fill | endwhile&lt;br /&gt;
:%s/\([^;]*\);\=/\=strpart(submatch(1).fill, 0, width)/ge&lt;br /&gt;
:%s/\s\+$//ge&lt;br /&gt;
&amp;quot; Highlight a particular csv column (put in .vimrc)&lt;br /&gt;
function! CSVH(x)&lt;br /&gt;
    execute 'match Keyword /^\([^,]*,\)\{'.a:x.'}\zs[^,]*/'&lt;br /&gt;
    execute 'normal ^'.a:x.'f,'&lt;br /&gt;
endfunction&lt;br /&gt;
command! -nargs=1 Csv :call CSVH(&amp;lt;args&amp;gt;)&lt;br /&gt;
&amp;quot; call with&lt;br /&gt;
:Csv 5                             : highlight fifth column&lt;br /&gt;
----------------------------------------&lt;br /&gt;
zf1G      : fold everything before this line [N]&lt;br /&gt;
&amp;quot; folding : hide sections to allow easier comparisons&lt;br /&gt;
zf}                               : fold paragraph using motion&lt;br /&gt;
v}zf                              : fold paragraph using visual&lt;br /&gt;
zf'a                              : fold to mark&lt;br /&gt;
zo                                : open fold&lt;br /&gt;
zc                                : re-close fold&lt;br /&gt;
&amp;quot; also visualise a section of code then type zf [N]&lt;br /&gt;
:help folding&lt;br /&gt;
zfG      : fold everything after this line [N]&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; displaying &amp;quot;non-asciis&amp;quot;&lt;br /&gt;
:set list&lt;br /&gt;
:h listchars&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; How to paste &amp;quot;normal vim commands&amp;quot; w/o entering insert mode&lt;br /&gt;
:norm qqy$jq&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; manipulating file names&lt;br /&gt;
:h filename-modifiers             : help&lt;br /&gt;
:w %                              : write to current file name&lt;br /&gt;
:w %:r.cfm                        : change file extention to .cfm&lt;br /&gt;
:!echo %:p                        : full path &amp;amp; file name&lt;br /&gt;
:!echo %:p:h                      : full path only&lt;br /&gt;
:!echo %:t                        : filename only&lt;br /&gt;
:reg %                            : display filename&lt;br /&gt;
&amp;lt;C-R&amp;gt;%                            : insert filename (insert mode)&lt;br /&gt;
&amp;quot;%p                               : insert filename (normal mode)&lt;br /&gt;
/&amp;lt;C-R&amp;gt;%                           : Search for file name in text&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; delete without destroying default buffer contents&lt;br /&gt;
&amp;quot;_d                               : what you've ALWAYS wanted&lt;br /&gt;
&amp;quot;_dw                              : eg delete word (use blackhole)&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; pull full path name into paste buffer for attachment to email etc&lt;br /&gt;
nnoremap &amp;lt;F2&amp;gt; :let @*=expand(&amp;quot;%:p&amp;quot;)&amp;lt;cr&amp;gt; :unix&lt;br /&gt;
nnoremap &amp;lt;F2&amp;gt; :let @*=substitute(expand(&amp;quot;%:p&amp;quot;), &amp;quot;/&amp;quot;, &amp;quot;\\&amp;quot;, &amp;quot;g&amp;quot;)&amp;lt;cr&amp;gt; :win32&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Simple Shell script to rename files w/o leaving vim&lt;br /&gt;
$ vim&lt;br /&gt;
:r! ls *.c&lt;br /&gt;
:%s/\(.*\).c/mv &amp;amp; \1.bla&lt;br /&gt;
:w !sh&lt;br /&gt;
:q!&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; count words/lines in a text file&lt;br /&gt;
g&amp;lt;C-G&amp;gt;                                 # counts words&lt;br /&gt;
:echo line(&amp;quot;'b&amp;quot;)-line(&amp;quot;'a&amp;quot;)            # count lines between markers a and b [N]&lt;br /&gt;
:'a,'bs/^//n                           # count lines between markers a and b&lt;br /&gt;
:'a,'bs/somestring//gn                 # count occurences of a string&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; example of setting your own highlighting&lt;br /&gt;
:syn match DoubleSpace &amp;quot;  &amp;quot;&lt;br /&gt;
:hi def DoubleSpace guibg=#e0e0e0&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; reproduce previous line word by word&lt;br /&gt;
imap ]  @@@&amp;lt;ESC&amp;gt;hhkyWjl?@@@&amp;lt;CR&amp;gt;P/@@@&amp;lt;CR&amp;gt;3s&lt;br /&gt;
nmap ] i@@@&amp;lt;ESC&amp;gt;hhkyWjl?@@@&amp;lt;CR&amp;gt;P/@@@&amp;lt;CR&amp;gt;3s&lt;br /&gt;
&amp;quot; Programming keys depending on file type&lt;br /&gt;
:autocmd bufenter *.tex map &amp;lt;F1&amp;gt; :!latex %&amp;lt;CR&amp;gt;&lt;br /&gt;
:autocmd bufenter *.tex map &amp;lt;F2&amp;gt; :!xdvi -hush %&amp;lt;.dvi&amp;amp;&amp;lt;CR&amp;gt;&lt;br /&gt;
&amp;quot; allow yanking of php variables with their dollar [N]&lt;br /&gt;
:autocmd bufenter *.php :set iskeyword+=\$ &lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; reading Ms-Word documents, requires antiword (not docx)&lt;br /&gt;
:autocmd BufReadPre *.doc set ro&lt;br /&gt;
:autocmd BufReadPre *.doc set hlsearch!&lt;br /&gt;
:autocmd BufReadPost *.doc %!antiword &amp;quot;%&amp;quot;&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; a folding method&lt;br /&gt;
vim: filetype=help foldmethod=marker foldmarker=&amp;lt;&amp;lt;&amp;lt;,&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
A really big section closed with a tag &amp;lt;&amp;lt;&amp;lt; &lt;br /&gt;
--- remember folds can be nested --- &lt;br /&gt;
Closing tag &amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; Return to last edit position (You want this!) [N]&lt;br /&gt;
autocmd BufReadPost *&lt;br /&gt;
     \ if line(&amp;quot;'\&amp;quot;&amp;quot;) &amp;gt; 0 &amp;amp;&amp;amp; line(&amp;quot;'\&amp;quot;&amp;quot;) &amp;lt;= line(&amp;quot;$&amp;quot;) |&lt;br /&gt;
     \   exe &amp;quot;normal! g`\&amp;quot;&amp;quot; |&lt;br /&gt;
     \ endif&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; store text that is to be changed or deleted in register a&lt;br /&gt;
&amp;quot;act&amp;lt;                                 :  Change Till &amp;lt; [N]&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot;installing/getting latest version of vim on Linux (replace tiny-vim) [N]&lt;br /&gt;
yum install vim-common vim-enhanced vim-minimal&lt;br /&gt;
----------------------------------------&lt;br /&gt;
# using gVIM with Cygwin on a Windows PC&lt;br /&gt;
if has('win32')&lt;br /&gt;
source $VIMRUNTIME/mswin.vim&lt;br /&gt;
behave mswin&lt;br /&gt;
set shell=c:\\cygwin\\bin\\bash.exe shellcmdflag=-c shellxquote=\&amp;quot;&lt;br /&gt;
endif&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot; *Just Another Vim Hacker JAVH*&lt;br /&gt;
vim -c &amp;quot;:%s%s*%Cyrnfr)fcbafbe[Oenz(Zbbyranne%|:%s)[[()])-)Ig|norm Vg?&amp;quot;&lt;br /&gt;
----------------------------------------&lt;br /&gt;
vim:tw=78:ts=8:ft=help:norl:&lt;br /&gt;
__END__&lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;quot;Read Vimtips into a new vim buffer (needs w3m.sourceforge.net)&lt;br /&gt;
:tabe | :r ! w3m -dump &amp;quot;http://zzapper.co.uk/vimtips.html&amp;quot;    [C]&lt;br /&gt;
:silent r ! lynx -dump &amp;quot;http://zzapper.co.uk/vimtips.html&amp;quot; [N]&lt;br /&gt;
&amp;quot; read webpage source html into vim&lt;br /&gt;
gvim http://www.zzapper.co.uk/vimtips.html &amp;amp;&lt;br /&gt;
----------------------------------------&lt;br /&gt;
updated version at http://www.zzapper.co.uk/vimtips.html&lt;br /&gt;
----------------------------------------&lt;br /&gt;
Please email any errors, tips etc to&lt;br /&gt;
vim@rayninfo.co.uk&lt;br /&gt;
&amp;quot; Information Sources&lt;br /&gt;
----------------------------------------&lt;br /&gt;
www.vim.org&lt;br /&gt;
Vim Wiki *** VERY GOOD *** [N]&lt;br /&gt;
Vim Use VIM newsgroup [N]&lt;br /&gt;
comp.editors&lt;br /&gt;
groups.yahoo.com/group/vim &amp;quot;VIM&amp;quot; specific newsgroup&lt;br /&gt;
VIM Webring&lt;br /&gt;
VimTips PDF Version (PRINTABLE!)&lt;br /&gt;
Vimtips in Belarusian &lt;br /&gt;
----------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>183.96.205.193</name></author>
	</entry>
</feed>