layer:11

an addiction to or an obsession with acquiring, manipulating, and sharing information

Undo Tree

A while ago, when I played around with E Text Editor, I was impressed by what they call a “Personal Revision Control”. It’s a nice concept, where instead of linear list of changes, which you can undo and redo, you can have branches.

For example, if you type “one”, then change it to “two”, then undo back to “one” and change it to “three”. In a typical text editor, now you would be able to go back to “one”, but not “two”. With E, you could switch between all changes, because it creates a new branch, when you go back and add a change.

Recently I discovered that Vim has had a feature like this (sans the pretty UI) for a long time, it’s called “undo tree”. Check out the documentation, but basically you can view branches with :undolist and time travel with :earlier and :later.

2010-02-23 22:25

Vim

Restore Cursor Position

Add the fallowing line to your .vimrc and when a file is opened, the cursor will be positioned to the same line it was left on, when this file previously was closed.

1 autocmd BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif

2009-12-27 19:28

Vim

Autocompletion

Vim has quite a few features for automatic text completion. The most basic is keyword completion - 1) open a file, 2) write first few characters of any word you see in the file, 3) hit CTRL+N to automatically complete the word. Simple, easy to use and very useful.

To make this feature more intuitive, consider mapping CTRL+Space to CTRL+N:

1 inoremap <C-Space> <C-n>
2 inoremap <C-S-Space> <C-p>

2009-12-13 21:30

Vim

| Archive | RSS | E-mail | Twitter | Alvis Mikovs