Blog - vim

Vim tricks

Sat May 5 13:48:21 EST 2007

[Some tips on using vim]. One thing that I've noticed on several hosts is that files open to the last position edited. To set this us use

set viminfo='20,\"50
autocmd BufReadPost * if line("'\"") | exe "'\"" | endif

or in general use '" to move to the mark of last position edited in the file. If you actually want to start at the front of the file then a quick 1G or gg will take you there.

Also found another [article on moving around in Vim].

[vim]

[permalink]

Seven habits of effective text editing

Wed Aug 9 13:23:03 BST 2006

[Seven habits of effective text editing] has some tips for using Vim to edit text:

  • To edit a file
    • Move around quickly using searches and editor capabilities for jumping to matching brackets (%) , variable definitions etc (gd)
    • Don't type things twice, use substitution and repetition. A period in edit mode repeats the last operation, so finding a word to replace, using cw to change the word and then repeating the find to get to the next word, followed by a period to repeat the change is a quick way of altering a file.
    • Fix it when it's wrong by defining abbreviations for common typos. eg abbr Lunix Linux
  • To edit multiple files
    • use :grep and :cn to find all occurences of a name in a group of files. Use multiple windows to edit several files at once.
    • use other programs to edit or filter text. For example select some text and use !sort to sort it. (...)

[vim]

[permalink]

Reference cards

Wed Aug 2 09:51:59 BST 2006

[Quick reference cards] for unix editors such as Vi and Emacs, as well as markup languages.

[unix] [vim]

[permalink]

How to insert timestamps in VIM?

Tue Apr 18 09:04:46 BST 2006

From[vim.org]

  - r! date (or r! date/T for time only)
  - "=strftime("%c")<enter>p

[code] [vim]

[permalink]

code (31)

erlang (6)
ideas (24)
lisp (1)
me (16)
notes (6)
ocaml (5)
physics (46)
qo (7)
unix (8)
vim (4)