author: http://www.moolenaar.net/vim.html this document assumes you are using my .vimrc (see dot_vimrc at page bottom). quickref: http://tnerual.eriogerg.free.fr/vimqrc.html tabs: tabe, tabf switch tab: tabn/tabp, gt/gT go to tab nr #: #gt tabpagemax vim -p files tabs to spaces: set expandtab multiple commands: separe by | command aliases: :Alias alias original define custom command: command -nargs=1 Name cmd help: :h follow link: include new: :helptags dir map: help map options/settings: toggoption set: set option set nooption set invoptionn option set: set option set nooption set invoption echo a setting: :set setting? see where it has been set: :verbose set setting? vim scripting: :help vim-script-intro prepend in v-mode: Prepend function ^ string prepend tab (indent): tab (< is built-in) prepend #: indent: normal mode: <<, >>, tab, shift-tab <,> tab gq, = leader: default: \ let mapleader = "," comments: with NERD_commenter: http://www.vim.org/scripts/script.php?script_id=1218 : comment: cc uncomment: cu toggle: c ci individually sexy: cs yank: cy to eol: c$ append: cA alternative: ca align delimiters: cl, cb others: cm let NERDSpaceDelims=1 /usr/local/share/vim/vim73/ftplugin/html.vim line 17 setlocal comments+=s: added the + so that in php it is still working! modelines/commands in comments: # vim: command surrounding: change: cs12 delete: ds( word: ysW( motion: ys line yss selected: s( (in visual) c comments: s* copypaste clipboard: vim --version: +xterm_clipboard is needed "+y or "+p empty command line: command line command to exec keycomb: mode keycomb insert single character: save and edit: we filename save as sudo: :w !sudo tee % > /dev/null pull/copy to command/paste to command line: save into register x and pull with x default: " =expr autocompletion: supertabs in commandline mode to see a list of suggestions open file: open file under cursor: gf f, gf open file in a new tab: go to url/go to link/open url under cursor: w open multiple files into tabs: http://linux.byexamples.com/archives/25/open-multiple-files-in-tabs-vim-7-can-do-that/ vim -p files made an alias fast find/file autocompletion/find file: i prefer command-t http://www.vim.org/scripts/script.php?script_id=1899 create cache: :FC find file: :FF split: :FS clear cache: :FCC command-t: https://wincent.com/products/command-t source the vba :h command-t CommandTFlush t in the prompt: use C-h/j/k/l in new tab: exit: ( doesn't work, dunno why) leg g:CommandTMaxHeight=1 command-line window (clw): open: from command-line mode , from normal q:,q/ can use : for commands. but not q: exit: execute, go to command-line, :q back to normal, execute current line in bash/shell: ! or ¨ to see results echo "hello" key notations (:help shift): = line split: , join: J insert blank line before/after: current: file % full path %:p directory %:p:h edit file relative to current file: :edit %:p:h... move line/selection: up: -, down: + m command visual mode: go to other end: o don't exit/stay in visual mode: stackoverflow: http://stackoverflow.com/questions/4711079/vim-how-to-stay-in-visual-mode-after-executing-a-command reselect/go back to selection: gv indent again: . reselect/select pasted block: gV registers: cut to register r: "rdd append to register r: "Rdd reload .vimrc: :source ~/.vimrc insert file contents/include file contents/load contents of file: :read file reload file: :e get line content: getline(lnr) current: getline('.') send to .vimrc: Sendtovimrc command go back: help jumplist mark: m{char}, back: '{char} see current marks: :marks to previous location: Ctrl+O Ctrl+I or `` '' to previous change: '. search: forwards/backwards: /, ? whole word: \ (I implemented it with \) repeat: n backwards: N (see also "previous location") search words in a line: /words.*separated.*like.*this using this kind of search is very useful in my notes because I write titles like a/b/c d/e - searchable with /b.*e for example in many files: vimgrep /pattern/ * (or ** for recursive) go to next match with :cn php: Phptags: sorrounds file with (uses mark p) documentor: http://www.vim.org/scripts/script.php?script_id=1355 text objects: i# doesn't select bounds, a# does word: w, w, W, W sentence: s, s paragraph: p, p: (don't confuse with )/} alone!) cool for deleting/indenting parenthesis/block: ) > } " ' custom: function: f, camelCasePart: ic indented block: i, l (including line below as well modified from original I) vim-indent-object: http://www.vim.org/scripts/script.php?script_id=3037 movements/go to: t{char}: till before occurrence of char to quote, parenthesis, semicolon: t", t), t; f{char}: till occurrence of char {/}: block/paragraph (/): sentence ga: go up one indentation level macros: start recording: q{char} stop recording: q replay macro: @q viewports/split: :sp C-w C-w C-w k same size: C-w = resize: C-w +/- swap: C-w r all: select all: delete all: dD select with S-Arrow: does not work. mapped and file specific setting: autocmd FileType ext cmd templates: http://slashraul.wordpress.com/2010/03/12/vim-templates/ autocmd BufNewFile * silent! 0r ~/.vim/skel/tmpl.%:e Tpl templatename, Etpl templatename located in mynotes/templates regular expressions: wikipedia is cool or: \| any order: .*red\&.*blue compile: make: F7, :make jump errors: :clist, :cp F9, F10 :cn, :cfirst, :clast first error: F8 special maps/custom/personal maps/commands/customizations: undo from insert mode: undo undo with C-y arrows exit insert mode moved Esc to caps-lock cmapped ö to nmapped ö to : mapped ä to / pipe to vim: | vim - rename: :saveas newname :!rm oldname make vim/custom vim notes: check what has been installed: vim --version on changes to configuration: make distclean install python-dev ruby ruby1.8-dev install: hg clone https://vim.googlecode.com/hg/ vim hg update v7-3-206 in src/Makefile uncomment: CONF_OPT_RUBY = --enable-rubyinterp CONF_OPT_PYTHON = --enable-pythoninterp CONF_OPT_FEAT = --with-features=huge make calls ./configure with the options set sudo make install long lines: :set wrap :set linebreak :set textwidth=width reformat: gq current par: gqap current line: gqq gj, gk instead of j, k breakindent: the solution is a patch, has some bugs http://sqizit.bartletts.id.au/2011/01/31/vim-and-breakindent/ https://retracile.net/wiki/VimBreakIndent https://retracile.net/attachment/wiki/2011/02/19/09.30/breakindent-20101112-vim7.3.diff sudo apt-get install libncurses-dev uninstall vim [[#custom vim install] delete before start position of insert: backspacing=indent,start,eol scrolling: scrolling relative to cursor: scroll-cursor, where you want current line: on top: zt (zw to start of line) on center: zz (z.) at bottom: zb (z-) scroll and keep cursor where it is , repeat last command: @: and then @@ sql: send queries to a db: http://www.davedevelopment.co.uk/2007/03/29/how-to-send-sql-commands-to-a-database-in-vim/ dbext: :h dbext.txt plugins: best 15: http://spf13.com/post/the-15-best-vim-plugins tags: for now the option to navigate through the files I like most is [[#command-t]] ctags: ctags cscope :h 29.1 generate install exuberant-ctags ctags *.c ctags -R . :set tags=maindir/**/tags jump to tag: :tag, :stag under cursor:  locally: gD in function: gd :tags autotag: update tags on save note that removed files are not updated -> needs manual update from time to time taglist: http://vim.sourceforge.net/scripts/script.php?script_id=273 :h taglist.txt :h taglist-options :TlistToggle if necessary Tlist_Inc_Winwidth=0 add files: :TlistAddFiles[Recursive] dir remove: d update: u let Tlist_Auto_Update=1 :TlistSessionSave file :TlistSessionLoad file jump to tag in new tab: t abbreviations!!!: abbr striong string decrement: increment: (not in my case) modeline: help modeline cool!