JohnBeckett (talk | contribs) (little more) |
JohnBeckett (talk | contribs) (some info from 602) |
||
Line 6: | Line 6: | ||
|complexity=basic |
|complexity=basic |
||
|author= |
|author= |
||
− | |version= |
+ | |version=7.0 |
|rating=43/22 |
|rating=43/22 |
||
|category1=Usage |
|category1=Usage |
||
Line 88: | Line 88: | ||
| <tt>``</tt> || jump back (to position in current buffer where jumped from) |
| <tt>``</tt> || jump back (to position in current buffer where jumped from) |
||
|} |
|} |
||
+ | |||
+ | ==See also== |
||
+ | *{{script|id=152|text=showmarks}} plugin to put a sign in the left margin for each mark |
||
==References== |
==References== |
||
Line 94: | Line 97: | ||
==Comments== |
==Comments== |
||
+ | The <tt>:delmarks</tt> command requires Vim 7.0. On previous versions, a kludge to remove all marks is to enter the command <tt>:%!cat</tt> (on Unix-based systems), or <tt>:%!type</tt> (on Windows). |
||
+ | ---- |
Revision as of 01:19, 21 May 2009
A mark allows you to record your current position so you can return to it later. There is no visible indication of where marks are set.
Each file has a set of marks identified by lowercase letters (a-z). In addition there is a global set for marks identified by uppercase letters (A-Z) that identify a position within a particular file. For example, you may be editing five files. Each file could have mark a, but only one file could have mark A.
As well as the letter marks, there are various special marks.
Setting marks
To set a mark, type m followed by a letter. For example, ma sets mark a at the current position (line and column). If you set mark a, any mark that was previously identified as a is removed.
Deleting marks
If you delete a line containing a mark, that mark is also deleted.
If you wipeout a buffer (command :bw), all marks for that buffer are deleted.
The :delmarks command (abbreviated as :delm) may be used to delete specified marks.
Command | Description |
---|---|
:delmarks a | delete mark a |
:delmarks a-d | delete marks a, b, c, d |
:delmarks abxy | delete marks a, b, x, y |
:delmarks aA | delete marks a, A |
:delmarks! | delete all lowercase marks for the current buffer (a-z) |
Using marks
To jump to a mark enter an apostrophe (') or backtick (`) followed by a letter. Using an apostrophe jumps to the beginning of the line holding the mark, while a backtick jumps to the line and column of the mark.
Using a lowercase letter (for example `a) will only work if that mark exists in the current buffer. Using a uppercase letter (for example `A) will jump to the file and the position holding the mark (the file does not need to currently be open).
- Each file can have mark a – use a lowercase mark to jump within a file.
- There is only one file mark A – use an uppercase mark to jump between files.
Command | Description |
---|---|
ma | set mark a at current cursor location |
'a | jump to line of mark a (beginning of line) |
`a | jump to position (line and column) of mark a |
d'a | delete from current line to line of mark a |
d`a | delete from current cursor position to position of mark a |
c'a | change text from current line to line of mark a |
y`a | yank text to unnamed buffer from cursor to position of mark a |
:marks | list all the current marks |
:marks aB | list marks a, B |
Special marks
Command | Description |
---|---|
`. | jump to position where last change occurred in current buffer |
`" | jump to position where last exited current buffer |
`0 | jump to position in last file edited (when exited Vim) |
`1 | like `0 but the previous file (also `2 etc) |
'' | jump back (to line in current buffer where jumped from) |
`` | jump back (to position in current buffer where jumped from) |
See also
- showmarks plugin to put a sign in the left margin for each mark
References
Comments
The :delmarks command requires Vim 7.0. On previous versions, a kludge to remove all marks is to enter the command :%!cat (on Unix-based systems), or :%!type (on Windows).