jumps and marks in vim

First we will talk about jumps in vim. Very useful for navigation and jumping around the vim. The jumps are commands that lets you jump from one location to another location, like {{ or [[ and so on … From the help file of vim

A \”jump\” is one of the following commands: \”\’\”, \”`\”, \”G\”, \”/\”, \”?\”, \”n\”,
\”N\”, \”%\”, \”(\”, \”)\”, \”[[\”, \”]]\”, \”{\”, \”}\”, \”:s\”, \”:tag\”, \”L\”, \”M\”, \”H\” and
the commands that start editing a new file.  If you make the cursor \”jump\”
with one of these commands, the position of the cursor before the jump is
remembered.  You can return to that position with the \”\’\’\” and \”“\” command,
unless the line containing that position was changed or deleted.

Now what good is a remembered if you cannot go to that location directly with a shortcut. Correct, shortcuts and lists of the commands are important and the developers of the best editor did not forget that (Note that you need the jumplist feature for this):

CTRL-O                  Go to [count] Older cursor position in jump list(not a motion command).
CTRL-I                  Go to [count] newer cursor position in jump list(not a motion command).In a |quickfix-window| it takes you to the position ofthe error under the cursor.

:ju[mps]                Print the jump list (not a motion command).

You can read more about jumps in the editor itself with \”:help jump\”

Now lets talk about marks. Marks can be assumed to be named jumps in most simple form. And adding a mark is also very simple

press m<any character/number>

m{a-zA-Z}               Set mark {a-zA-Z} at cursor position (does not move the cursor, this is not a motion command).m\’  or  m`              Set the previous context mark.  This can be jumped to with the \”\’\’\” or \”“\” command (does not move the cursor, this is not a motion command).
m[  or  m]              Set the |\'[| or |\’]| mark.  Useful when an operator is to be simulated by multiple commands.  (does not move the cursor, this is not a motion command).

and jumping to a mark can be done in two ways:

1. With ` (backtick):     The cursor is positioned at the specified locationand the motion is |exclusive|.
2. With \’ (single quote): The cursor is positioned on the first non-blank character in the line of the specified location and the motion is linewise.

To list all the marks you can use the command marks as so:

:marks {arg}            List the marks that are mentioned in {arg}

*:delm* *:delmarks*
:delm[arks] {marks}     Delete the specified marks.  Marks that can be deleted include A-Z and 0-9.  You cannot delete the \’ mark.

There are three classification of the marks based on how they can be used or defined :

\’a – \’z         lowercase marks, valid within one file
\’A – \’Z         uppercase marks, also called file marks, valid between files
\’0 – \’9         numbered marks, set from .viminfo file

You can read more about marks in vi editor with \”:help marks\”

You can get some info at the below link also:

http://www.linux.com/archive/articles/54159

\"Reblog

2 thoughts on “jumps and marks in vim”