How to find stuff

Please use Browser Search or Scroll down.

vim navi

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

when in insert mode

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

colors highlighting

create .vim/ftdetect/foo.vim and add this

autocmd BufRead,BufNewFile *.txt set filetype=txt

in ~/.gvimrc_ add txt filetype

au BufNewFile,BufRead /data/files/* set filetype=txt _orange_ __red__ +green+ ++purple++

in ~/.gvimrc add foo filetype:

au BufNewFile,BufRead /data/files/* set filetype=help.addcolors create .vim/syntax/addcolors.vim and add this: " available colors "================ "red cd6a43 "orange fdb86b "green 7a9c6c "grau 888888 "blue 2d5393 "purple c6b7ec syn match cTransA "_.*_" contains=delimA syn match cTransB "+.*+" contains=delimB syn match cTransC "__.*__" contains=delimC syn match cTransD "++.*++" contains=delimD syn match delimA contained '_' conceal syn match delimB contained '+' conceal syn match delimC contained '__' conceal syn match delimD contained '++' conceal hi cTransA ctermfg=cyan guifg=#fdb86b hi cTransB ctermfg=red guifg=#7a9c6c hi cTransC ctermfg=red guifg=#cd6a43 hi cTransD ctermfg=red guifg=#c6b7ec hi cTransA ctermfg=215 guifg=#fdb86b hi cTransB ctermfg=107 guifg=#7a9c6c hi cTransC ctermfg=131 guifg=#cd6a43 hi cTransD ctermfg=104 guifg=#c6b7ec (create _.vim/ftdetect/foo.vim_ and add this:) autocmd BufRead,BufNewFile *.foo set filetype=foo

src

http://ftp.vim.org/pub/ftp/editors/vim/runtime/syntax/help.vim regex meanings https://regex101.com/

get processing syntax for vim

download this

http://www.vim.org/scripts/script.php?script_id=2115 copy syntax/processing.vim to .vim/syntax folder

add this to .gvimrc

"set filetype html for *.pde processing au BufNewFile,BufRead *.pde set filetype=processing

marks

(works like recording) ma set mark on current line (ma,ms,md,mf) 'a jump to mark a ('a, 's, 'd, 'f) 'a v 's d to delete/copy selection usw

get processing syntax for vim

download this

copy syntax/processing.vim to .vim/syntax folder http://www.vim.org/scripts/script.php?script_id=2115

add this to .gvimrc

"set filetype html for *.pde processing au BufNewFile,BufRead *.pde set filetype=processing

search and replace umlaute with a shortcut

copy this in .gvimrc

map <F4> :s/ae/ä/g\|'<,'>s/oe/ö/g\|'<,'>s/ue/ü/g<CR><CR>

usage

v to select text, then press f4 example: But you'll have to escape it in the map command :map <F3> :%s!<!\&lt;!g\|:%s!>!\&gt;!g<CR>

shortcut to change working path fast

put this in .gvimrc

" CDC = Change to Directory of Current file "command CDC cd %:p:h command CDC cd /Volumes/FOLDER/

usage

:CDC to change to path

easygrep

:Grep <Pattern> :GrepOptions http://www.vim.org/scripts/script.php?script_id=2438

search &quot;reactor&quot; in several files

:cd projectpath :noautocmd (to speed things up) :vimgrep /titletext/j ** :vimgrep /titlebar/j **/*.css :vimgrep /reactor/j ../**/*.php :cw :cn 'or' :cp (jump to files) j, k select file -> ctrl + w, f 'or' gf 'or' gF to open file

vim scripting

:help vim-script-intro

yank these lines

:let i = 1 :while i < 5 : echo "count is" i : let i += 1 :endwhile

then :@&quot; to execute

(home) registers copy and paste

xp switch characters ddp switch lines # to search for the word under cursor! crtl r + a to paste from register 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)

nerdtree

f2 open nerdtree b open bookmarks shift d delete the current bookmark p jump to parent dir s open in vertical split i open in horizontal split m display DELETE dialog t open file in new tab, stay in nt ? Help :Bookmark newmark create new bookmark :ClearBookmarks NAMES delete bookmark

vimium

/: find mode (just type away..) x close tab yy copy URL gs view page source j or k up/down f open links shift + f open links in new tab shift + j/k cycle through the tabs b open bookmarks (type here!) ? show shortcuts

number sequence

:r! for i in $(seq 1 10); do echo "This is line \#${i}"; done :r! for i in $(seq 1 10); do echo "'row-${i}\"',"; done

rename in several files at once

:args **/*.txt (projectfolder/subfolder) :set hidden (navigate away without save) :argdo %s/OLDWORD/NEWWORD/ge | update (ge to supress error msg, update to save) :ls :b 4 (to jump to buffer 4) :b tab (really cool with wild menu)

put this in ~.gvimrc to tab through buffers

set wildchar=<Tab> wildmenu wildmode=full set wildcharm=<C-Z> nnoremap <F10> :b <C-Z> <f10> :b tab

command line from vim

cd something, start vim $ grep -n Menu * (access external) or :grep Menu * (build in vim) !ls (! is firing off a one off command, $ not) :shell to enter a shell

nerdtree

f2 open nerdtree b open bookmarks :bookmark newmark create new bookmark d delete the current bookmark p jump to parent dir s open in vertical split i open in horizontal split m display DELETE dialog t open file in new tab, stay in nt ? Help

vimcast

http://vimcasts.org http://vimeo.com/vimlondon/videos

autokorrektur von typos

:iabbr the the :iabbr -> →

Folding

put this in .gvimrc: nnoremap <Space> za create a fold with zf then toggle folds with SPACE

Tabs

install tabular.vim one = 1 two = 2 three = 3 four = 4 ,a= title: "Aligning assignments" h264Src: "/media/alignment.mov", oggSrc: "/media/alignment.ogv" posterSrc: "/media/alignment.png" duration: 320, ,a:

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

tcomment

installation

copy vba file into plugin folder :so %

usage

comment gc uncomment gc

more src

http://vim.wikia.com/wiki/VimTip271

draw a box

open lines with tabs \ l (to show tabstops and line ends) crtl + V (vertical selection), move down crtl + I (insert), create some tabstops crtl + V, press $ r # move to 2nd line, 2nd letter crtl + V, draw selection r <space> R (to write)

indenting

command + [

.gvimrc:

nmap <D-[> << nmap <D-]> >> vmap <D-[> <gv vmap <D-]> >gv

autoindenting html files

ggVG (select all) command + [ to remove indents ggVG =G (to autoindent)

show hidden characters

insert this into .gvimrc

" mapping hidden characters to short cut "\ l" " Shortcut to rapidly toggle `set list` nmap <leader>l :set list!<CR> " Use the same symbols as TextMate for tabstops and EOLs set listchars=tab:▸\ ,eol:¬ "Invisible character colors highlight NonText guifg=#4a4a59 highlight SpecialKey guifg=#4a4a59

switch syntax to html

in .gvimrc

open MacVim :cd :e .gvimrc au BufRead,BufNewFile *.ss set filetype=html

oder live:

:setf c :setf html :setf php ... :set syntax=html

macros in text files

in macvim

:e ~/.vim/snippets/_.snippets

oder terminal go to .vim/snippets vim _.snippets (globale snippets :))) ${1:VORGABE1} // vorgabe1 wird definiert per tab zum naechsten springen! $(2:$1) // vorgabe1 wird eingefuegt tab $(3:VORGABE2} // vorgabe2 wird definiert usw ${4:$3} // vorgabe2 wird eingefuegt

rename

: %s/75/272/g (find all 75 und rename to 272)

mehrere zeilen einruecken

ctrl + v zeilen markieren (nur erstes zeichen) shift + i tab esc 'margin' ---------------------------------------------------- :set wm=10 'tags' =helplinks ---------------------------------------------------- crtl t back crtl ] forward (if cursor is on link) '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 'taschenrechner' ---------------------------------------------------- crtl+r = 1+3 strftime('%c') 'registers' ----------------------------------------------------

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 'makro' 'macros' --------------------------------------------------------------- <ESC> 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;http://www.microsoft.com/;http://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 'edit' --------------------------------------------------------------- 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> Key mapping (http://www.vim.org/htmldoc/usr_40.html) mehrere zeilen auskommentieren: markieren mit Strg-V und dann I # dann ESC drücken alles lower case: V u upper V U close vim Z Z Umlaute "a oder "A '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 - vim2html :runtime! syntax/2html.vim :let use_xhtml = 1 :let html_use_css = 1 .vimrc ändern: let use_xhtml = 1 let html_use_css = 1 abbr 2html <Esc>:runtime! syntax/2html.vim <CR> /usr/share/vim/vim64/syntax/2html.vim zeile 197 folgernd ändern: exe "normal! a<html>\n<head>\n<title>Info\e" zeile 198 folgernd ändern: exe "normal! a</title>\n\e" zeile 200 folgernd ändern: exe "normal! a<meta name=\"Generator\" content=\"Vim" . '"' . tag_close . "\n\e" vimtutor eintippen! (http://www.strcat.de/tmp/tutor.ge) http://www.viemu.com/vi-vim-cheat-sheet.gif syntax highlighting einschalten:

vim ~/.vimrc

:r $VIMRUNTIME/vimrc_example.vim :w tabstop :set tabstop=4 autoeinrückung :set autoindent :set noautoindent zeilennummer :set number :set nonumber 'dateistuff' --------------------------------------------------------------- dateibrowser Sex oder e . o (open file in new window) - (ebene höher) zeile 20-25 extern :20,25w dateiname externes einlesen :r dateiname neues fenster :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 'nerdtree' --------------------------------------------------------------- F2 to open NERDtree hjkl to navigate the files. o to open the file in a new buffer or open/close directory. t to open the file in a new tab. p to go to parent directory. r to refresh the current directory. B to turn on Bookmarks I to show hidden files Bookmark NAME RevealBookmark NAME OpenBookmark NAME ClearBookmarks NAMES ClearAllBookmarks transparency macvim -> preferences -> enable experimental renderer