Excellent vim doc: http://www.ukuug.org/events/linux2004/programme/paper-SMyers/Linux_2004_slides/vim_tips/ help :help keyword CTRL-D The CTRL-D shows completion matches. The help system uses tags, so see TAGS below. Manual notation = \x80 is high-bit). utf8 digraph keys (first + : + second) ----------- ¯- ä \0344 \xe4 a: Ä \0304 \xc4 ... ö \0366 \xf6 ... Ö \0326 \xd6 ... ü \0374 \xfc ... Ü \0334 \xdc ... ß \0337 \xdf ... « \0253 \xab << » \0273 \xbb >> ° DG Vim digraphs means that you enter two keystrokes to make one character. (:set digraph) The character itself may be 1 or 2 bytes (1 for latin1 and 2 for extended utf-8 characters). Like "Ctrl-K a:" or "a:" --> umlauted "a". (the 1-char output may be 1 or 2 bytes). UTF-8: Special characters stored in 2 bytes. Remember, digraph is just Vim's very convenient method to enter special characters. Encoding (utf-8 vs. latin1, etc.) is set via "set encoding=..." or env var. LANG, *LC*, etc. RedHat screws up foreign characters. With some terminal emulators, you can not see the foreign characters no matter what. When you can see them, digraph sequences create 2-character outputs. They show file type of "UTF-8 Unicode English text". ä 228 = \0xe4 \0344 + Ä \0304 + ü \0374 + Ü \0334 + ö \0366 + Ö \0326 + « \0253 + » \0273 + ß \0337 + Digraphs are NOT supposed to be 2-character sequences! (I think that this depends on encoding). WRONG. Control mode (not ex mode) command "ga" tells decimal/hex/octal value/code of character currently under the cursor. ISO-8859/UTF-8 Unicode (2-char "digraph" sequences) Digraphs work good (:help dig), but don't show up with some terminal emulators. With "set digraph": (Seems that files with digraphs are called "UTF-8 Unicode". (I seem to recall them being identified as ISO-8859 in some contexts though). Digraphs are 2-character sequences. German letter digraphs all begin with 0xc3. (e.g. ö = \0xc3 \0x96 = \0303 \0226) But « and » begin with 0xc2. a:, etc. ss Extended ASCII (1-chars) :help i_CTRL-v_digit -v + { Control or Alt sequence OCTAL xHEX u4CHARHEX U8CHARHEX } VIM encoding values latin1 == ISO-8859-1 utf-8 == UTF-8 Can set character DISPLAY encoding with :set encoding=X ! Generally DO NOT CHANGE THIS ! This just needs to satisfy your terminal emulator; changing it can hose yor file content! Can set character WRITING encoding with :set fileencoding=X Defaults according to LANG variable or OS or setting in .vimrc. Otherwise uses value from env var $LANG (which is UTF-8 w/ SUSE). (vim translates env vars to lower-case). Can convert a file's encoding by simply changing 'fileencoding' and writing again. FILES always written according to 'fileencoding'. If that not set then according to 'encoding' (regardless whether file new or not). THINGS GET FUCKED UP if you change 'encoding' with a file loaded. It actually changes the file bytes and the file will not get written according to 'fileencoding' EXISTING FILES get 'fileencoding' set automatically according-to-the-file when file is loaded. AND 'encoding' gets set according to '--cmd encoding=x' OR LANG=x vim... or OS. But I don't think there's any advantage to ever changing this from utf-8, since that will handle characters in all of my files (if start using 4 byte characters then consider utils utf-16). :digraphs lists all available digraphs. To set indent size of 2 for XML files, add set shiftwidth=2 ts=2 to the bottom of VIMHOME/indent/xml.vim. SEEMS THEY HAVE FIXED THE CONFIG FILE RUNTIMEPATH NOW! See your runtime path with ":set rtp". Should list $HOME/.vim up top. Put your filetype-specific indent settings in $HOME/.vim/indent/EXTENSION.vim. Like set sw=2 ts=2 To stop gvim from starting up with its own bad estimation of the window width you need, use .vimrc/.gvimrc setting "set columns=80". gvim == vim -g Can use "echo 'x'" in .vim files. Will display a popup or write to status line, depending on current mode. :set rtp to echo the runtime path. This is where you need to create subdirectories ftpdetect and ftplugin. Put filetype-handlers in ftplugin, like vimfiles/ftplugin/text.vim to hand *.text files. I have a note with subject "great putty .vimrc command" that says: hi Normal ctermfg=white ENDCODING conversion: iconv -f iso-8859-1 -t utf-8 -o new.utf8 # writes stdout by default # Does not do in-place conversions The Suse release notes imply that ISO8859-1 is legacy. I guess UTF8 is what you should use if you need internationality. INSERTION COMPLETION :help ins-completion CTRL-N tries to auto-complete with something in current doc or tags. It is not fs-type-specific. CTRL-P is supposed to search in opposite direction, but I see no difference. (CTRL-X CTRL-N is very similar but just looks in current file). CTRL-X Ctrl-O OMNI-Completion. FS-type-specific. CTRL-X lists ins-completion types available Ctrl-E Escapes out. TABBIFYING COMPLETIONS Throw supertab.vim into $HOME/.vim/plugin directory. Says it does CTRL-P by default, but it is doing CTRL-N + CTRL-P. See "Global Variables" in supertab.vim for how to change. Can change at runtime with ":SuperTabHelp". With my ~/.vimrc additions, seems to work with +p TAGS. Keywords that you can "drill down". The source location is colored Magenta. Identifying keywords. Cyan (with my setup). Green (with my setup) Some blue words??? These are for tagged "words". Won't work unless tags have been generated for your doc using "ctags" or similar program (has been done for vim help). FORWARD ":tag word" Ctrl-] double RETURN ":pop" CTRL-T (Or, CTRL-O more generally Jumps back) ":tags" shows current tag stack SHIFT-click. Highlights the clicked work in all occurrences. FS TRAVERSAL Just open a directory. Enter on an entry to open a file or directory. CTRL-O to back out. CTRL-Z CTRL-F to ins-completion a filepath. SPELL CHECKING While in insert mode: Ctrl-X s Must turn on PER DOCUMENT with ":setlocal spell spelllang=en_us" eclim project may be for integration of vim with Eclipse. CHANGING CASE/Capitalization Operation: U = Upper; u = lower; ~ = invert Scoper: repeat Op. is line; w is word; G to-end-of-doc; j3 to-3-lines-down; k4 to-4-lines-up guu current line gUU current line g~~ current line gu gU FOLDING = z* commands. Nomenclature: fold vs. open Folding (vim) = Closing = Collapsing (general), thus fold = close = collapse Open = expand = unfold Levels are global. If I am at global level 2 anywhere and do zm, it will fold elements with content to level 2 globally. zfap: create a Paragraph fold zo: Open (expand) current fold zc: FOLD = Close (collapse) current fold zr = zo *: Reduce Folding at current level zm = zc *: More Folding at current level zR = zo *: Reduce all Folding zM = zc *: More all Folding zi: Toggle folding foldcolumn's are EXTRA columns to the left to indicate folding. Defaults to 0. In graphical mode, the indicators can be clicked to fold/open. IMPORTANT: Must increase winwidth to accommodate the extra columns! XML http://www.pinkjuice.com/howto/vimxml/ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! FUCKING $HOME/.vim/after/*/* files DON'T FUCKING WORK HALF THE TIME!!!!!!!!! They are executed, but have no effect on ft-specific settings. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Seems this problem may have to do with "autocmd" commands. My text.win commands to set textwidth to 80 have NO EFFECT. But if I put autocmd FileType text setlocal textwidth=80 in plain .vimrc, it just works. WRAPPING "textwidth" setting controls what is the more important aspect of wrapping-- automatic insertion of line breaks into the data. The "wrap" option just controls whether or not to visually-wrap-vs-visually-truncate lone lines in the vim window. N.b. vim defaults textwidth to 78 for text files (with local setting via autocmd). This is a really bad setting IMO, since you are changing data to accommodate presentation conditions which are usually not present. Better to size lines to 80, which works directly with most use cases. It's pretty rare to need "nowrap" mode or foldcolumn's when you can't resize the Windows. Even a remote terminal emulator can resize vim text windows. gvimdiff colors: Real changes are in Light gray-blue (not plain light-blue) Red ga shows character info Great reference: http://www.pixelbeat.org/vim.tips.html EASY MODE Looks like best for the ignorant is "egvim" == "vim -y -g". How set easy Y mode from .vimrc file? VIM is used to override ~ for user-specific config files. VIMRUNTIME is obviously for the shared distro files. Backup files. Disable with: :nobackup (says may also need :nobackupwrite or similar) :set backupdir=~/path1 :set backupdir+=/dir2 :set backup :set backupext=.bak Beware of :backupskip Encryption: Encrypt with command: :X and then CHANGE FILE! and save (regularly). OR write to a new file with :w newfile.txt If you don't save the file then it won't really save at all (even with !). Save decrypted with command: :set key= (or :X with empty str) and then CHANGE FILE and save. OR write to a new file Damned good thing: Encrypting with empty string is same as encrypting with nothing. Therefore if you accidentally do ":X" just give it empty string twice and nothing will encrypt. Changing capitalization/upper-case/lower-case ~ operator toggles U upper-cases u lower-cases g[Uu~] g[Uu~][Uu~] or V[Uu~] does it to current line ggg[Uu~]G does it to entire file Search for non-ASCII character DON'T WORK: yl (that is an L) / ga tells what the character is Then search using hex: /\%x1b or with Ctrl-V + sequence like /@ to search for \0 To toggle line-numbering: :set number|nonumber For better regexp goodness, extended patterns/regular express, need to prefix regexp with \v for "very magic". Quick is-very-magic-active test: search for " means at end. \b still does not work! [To search for any character other than \w characters, you must search for \X ] ??? Search for \x\W seems to work great. ??? There is no way to make this the default, so need hacks documented at http://vim.wikia.com/wiki/Simplifying_regular_expressions_using_magic_and_no-magic nnoremap / /\v vnoremap / /\v cnoremap %s/ %smagic/ cnoremap \>s/ \>smagic/ nnoremap :g/ :g/\v nnoremap :g// :g// File suffix associations in Windows. At least with Windows 10, can't use UI for this any more. assoc .txt ftype txtfile="C:\path to gvim*.exe" "%1" SWAP/BACKUP/UNDO Files To prevent tons of temp files all over the place like weeds, use dedicated directories. The undo dir valid since vim v.7.3. mkdir -p ~/vim.d/backup.d ~/vim.d/undo.d ~/vim.d/swap.d set backupdir=~/vim.d/backup.d// set undodir=~/vim.d/undo.d// set directory=~/vim.d/swap.d// The final // says to translate "/" in paths to %. Append ",/dir/ectory" to add backup directories, e.g. ",c:/Windows/Temp//" nmaps like so. N.b. ex commands required a line break after. Compound: You type the "=j" in regular non-insert mode, not in ex mode. nmap =j :%!python -m json.tool :%s/ / /g gvim Edit > Select All doesn't work well, so memorize: ggVG Allow to scroll cursor (not just view) to very beginning or end of document: set scrolloff=0 Select-all by gvim pulldown menu usually takes me from 2 to 6 attempts. Fuck that. Just use key sequence ggVG. Entering characters by character number, like for binary characters. CTRL+V NNN decimal CTRL+V oNNN (from oN) hex CTRL+V xNN hex CTRL+V uNNNN hex To persist font setting create or add to a ~/.gvimrc with something like: set guifont=Lucida_console:h16 diff mode without -o (or is it -O?) splits into L & R panels. In non-graphical mode you can move the vertical divider position with: vertical resize 40 (with CTRL+w focus in the panel to resize). To sort contents with or without uniquifying: :sort :%sort u