April 1, 2009

vim marks

Marks

You can set marks within your documents to jump quickly between different positions of a document or even many documents.

Vim automatically sets various marks like

* {0-9} are the last 10 positions of closed files (0 the last, 1 the last but one)
* <> are the left and right position of marked texts
* ( and ) are the start or end of the current sentence
* { and } are the start or end of the current paragraph
* [ and ] are the first or last character of the last yanked or changed text
* . position of the last change
* ' or ` position before the last jump
* " position before the last exit of the file (local to a file)
* ^ position of the last insert-stop

To set a manual mark, use m{a-zA-Z} (m followed by either a,b..z or A,B,..Z), and to jump to one of the marks (manual or automatic) you can choose between ' and `

* ' ...sets the cursor to the first non-blank character in the marked line
* ` ...sets the cursor to the exact position where the mark was set

There is a little difference between lower-case and upper-case characters:

* {a-z} are local to a file
* {A-Z} are stored and available over sessions (associated with a file)

You can use L for your work-log and T for your time-table for example, and quickly update the information there.

For example you can jump to the last known position of a file before it was closed by typing `" (it’s easy to configure Vim to do it automatically at start).

To get a list of all marks Vim knows about type :marks. To delete marks use :delmarks (:delmarks a b c removes marks a and b and c, to delete all marks use :delmarks!).

More tips at http://blog.interlinked.org/tutorials/vim_tutorial.html

No comments:

Post a Comment