vim: ft=help:tw=78:ts=8:norl:nolist:nonu:noml:
notes for Shortcuts vim :


vim navigation

    fast up/down        [
    jump page top       H
    jump page middle    M
    juml page bottom    L

    page up/down        crtl + f/b
    next paragraph      {
    copy word           yiw
    select word         viw
    paste over          viwp

    s/old/new/g         replace visual selection

when in insert mode

    copy line       yy
    enter           crtl + j/h
    delete word     crtl + w
    copy line       yy


registers copy and paste

    xp              switch characters
    ddp             switch lines
    #               to search for the word under cursor!
    crtl r + a      to paste in insert mode, works in command line mode too

    yiw                 copy current word into default reg
    viw                 to select current word
    p
    crtl r  a  reg    to paste in insert mode from reg (a, s, d)

    crtl + o                leave insert mode for 1 command

    <crtl + p> <crtl + n>       circle up history



move lines up/down

    v (to select)
    cmd + shift - up/down


split windows

    crtl + w, v         split window vertically
    crtl + w, s         split window horizontally
    :vsp filename       split vertically filename
    :sp filename        split horizontally filename

    crtl + w, w         cycle next window
    crtl + w, h         focus left window
    crtl + w, l         focus right window
    crtl + w, j         focus down window
    crtl + w, k         focus upper window

    crtl + w, =         equalize windows
    crtl + w, x         switch windows
    crtl + w, r         rotate window


indent multiple rows in VIM

    ctrl + v
    zeilen markieren (nur erstes zeichen)
    shift + i
    tab
    esc


sessions

    :mksession <file>           save session
    :source <file>              restore
    vim -S <file>               restore


dictionary

    :set spell        turn on spellcheck
    z=                move cursor over word and hit z =


marks

    mq              sets mark on letter q
    `q              jumps to the mark on q
    :marks          shows all current marks
    d`q             delete from mark to cursor
    ``              moves between the last 2 locations
    `.              jumps to line with last modification


registers

    while in insert mode

    crtl+r /        /searchterm


normal mode

    q/            search history, then press enter to get it into register
    "1y           yank selection into reg 1 (in visual mode)
    "2p           paste content of reg 2
    :6d1          delete line 6 into register 1
    :reg          show register
    :reg 2        show content of register 2
    "2            use register 2 for next delete, yank, put
    u             undo
    crt+r         redo
    g-            more undo (when already overwritten!)
    :earlier 10m  travel 10min back in history time
    :later 5m     jump ahead 5 min



macros

    q 1     start recording in register 1
    q       stop
    <ESC>
    @1      execute recording in register 1 (not :@1  !!)
    5@1     execute 5 times (make sure line jumps are in makro!)


replace

    :'<,'>s/old/new/g         replace visual selection
    %s;www.microsoft.com/;www.linux.org;g
    1,8s/<[^>]*>//g           Remove all html tags (ie strings enclosed in <> ) in lines 1 to 8
    /^[A-Z].*\. *$            will search for any line that begins with a capital letter and ends
                           with a period and any number of blanks
    /[^c]an                   will search for any "an" preceded by any character other than a c
    /[a-z]as                  search for any lowercase letter followed by "as"
    /[0-9]\{3}[ -][0-9]\{4}   search for any 7 digit phone number
    /foo.*bar                 Find each occurrence of 'foo' with some stuff in between foo and bar
    %s/foo/bar/g		Find each occurrence of 'foo', and replace it with 'bar'
    %s/foo/bar/gci		Change each 'foo' (case insensitive) to 'bar'; ask for confirmation.
    s/foo/bar/g    		changes each 'foo' to 'bar' in the current line.
    %s/foo/bar/g    	changes each 'foo' to 'bar' in all lines.
    5,12s/foo/bar/g    	changes each 'foo' to 'bar' for all lines between line 5 and line 12.
    %s/\<foo\>.\{5}// 	On each line, delete the whole word "foo" and the following five characters.
    g: global
    c: confirmation
    i: case insensitive
    I: case sensitive
    :%s/Someting.*somethingelse/replacetext/g      .* is wildcard of any number of letters


folding

    {Visual}zf :Operator to create a fold.
    zf to create fold (after selecting in in visual mode)
    zo and zc open/close ONE fold
    zm and zn open/close ALL folds
    zE   deletes all folds.
    za toggle current fold, open/close
    zj jump forward one fold, zk jump backwards one fold


editing

    insert at beginning of line         I
    insert at end of line               A
    substitute line                     S
    change uppercase/lowercase          v to select, then gU for uppercase, gu for lowercase
    syntax autocomplete                 crtl-x crtl-o
    go to line 54                       54G
    continue editing                    gi
    exit                                ZZ  ZQ
    reload file                         e!
    delete from current line to end     dG
    exit insert mode                    crtl + c (!) wort 	ersetzen	    	c w
          loeschen	                    d w
          kopieren         	            y w
          markieren	                    v w
          ueberschreiben                R

    ganze zeile
          ersetzen             S
          loeschen	            d d
          kopieren	            y y


    rest zeile 	kopieren	y $
          ersetzen	            c $
          loeschen	            d $
          markieren	        v $

    new line below/after		o / O
    join lines			        J
    markieren			        v $
                               v 0
          vertikal	crtl + v
    erneut markieren		g v
    paste				p
    zeile einruecken	markieren, dann shift+>
    buffer 2-0/a-z 	write		" h y
          read		" h p
    undo				u
    redo				crtl + r
    buchstaben 	ersetzen 	r
          loeschen	x
    auto-complete	word		crtl + p
          line		crtl + X L
    replace				:%s/alt/neu/g
    innerhalb der markierung	:'<,'>s/alt/neu/g
    regex
    repeat				.
    5x repeat			5 .
    makro record 	start		q a
          stop		q
          run		@ a
          run 100x	100 @ a


abkuerzen (in .vimrc)

    :ab hh heidi hoppla
    :iab ä \"{a}<Esc>Bhx2e a
    :iab <p> <p> </p><Esc>bbhi
    :iab asdf <?php echo ?><Left><Left><Left>



uncomment multiple rows

    mark with crtl-v and then press i, ESC
    lower case:		V u
    upper			V U
    save and close  Z Z


navigation

    {}         next paragraph
    crtl+f     page down
    crtl+b     page up


    i              insert mode
    R              Replace mode
    :177   goto line 177
    {      previous, next paragraph
    *      search next under cursor
    H      top of page
    M      middle of page
    L      bottom
    500G   line 500
    *      searches for the word unter cursor, hit n und N to jump to next
    50%                       to go to middle of document
    (   )                      move to next/previous sentence
    {   }                     move from paragraph to paragraph
    :3			go to line 3
    w   &    b 		go to next/previous word
    0	 			go to beginning of line
    $				go to end of line
    O				insert above line
    o				insert below line
    I				insert beginning of line
    A				insert at the end of line
    to switch between tabs:       ⌘⇧[ / ⌘⇧]
    Page	down			crtl + d/f
    up			crtl + b
    cursor 	page middle		M
       page top	H
       page bottom	L
    cursor line	beginning	ENTER
       end		-
    jump next 	word		w
       bigword		W
    jump last 	word		b
       bigword		B
    jump back last edit		crtl + o
    zu zeile 200 springen		200 g g
    zeilennummer			crtl + g
    dokument-anfang		g g
    dokument-ende			G
    zur zeile springen		NUMMER G
    suchen 				/
       next		n
       previews	N
       ignore case 	:set ic
       colorize	:set hls is
    open links in helpfile		Strg-AltGr-9
    zoom		nach unten	z enter
       mitte		z .
       nach oben	z -



file handling

    dateibrowser			Sex or e .
               o 	(open file in new window)
               - 	(level up )
    row 20-25 extern		:20,25w dateiname
    read external file      :r dateiname
    new window              :sp dateiname 	(vertikal :vs)
    wechseln		Crtl + W   	(2mal)
    groesser		Ctrl + W  _
    alle gleich  Ctrl + W  =
    C+w s		            - horizontal split view
    C+w v 	            	- vertical split view
    C+w {h,j,k,l}      	- move to window in respective direction
    :sp                    - horizontal split
    :vsp                   - vertical split



externalcommands

    :r filename     embed a file in document
    :r! command     execute system commands (ls)
    :r! date        put date into a file
    V then !sort    filter a region through a command
    :sh             opens a shell
