Skip to content

Instantly share code, notes, and snippets.

@tlatsas
Last active December 21, 2015 14:08
Show Gist options
  • Save tlatsas/6317042 to your computer and use it in GitHub Desktop.
Save tlatsas/6317042 to your computer and use it in GitHub Desktop.
vim tips

replacing

spaces -> tabs (w range)

:183,200:retab!

remove trailing space

:%s/\s\+$//

or, because the substitution text can be omitted if blank:

:%s/\s\+$

modeline examples

// vim: noai:ts=4:sw=4
   -or-
/* vim: noai:ts=4:sw=4
*/
   -or-
/* vim: set noai ts=4 sw=4: */
   -or-
/* vim: set fdm=expr fde=getline(v\:lnum)=~'{'?'>1'\:'1': */

searching

find whole words

Put the cursor anywhere inside a word and press * or encapsulate your search term in \< and \>.

bookmarks

To add a bookmark in a vim file use the m character plus a character in the range (a,z) (for local files) or (A-Z) (global). Eg ma will create the mark a in the current file. To jump to mark a, use `a (jump to line+column) or use 'a (jump to the beginning of the line).

misc

abrevations

:ia <short> <long>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment