sponsor Vim development Vim logo Vim Book Ad

basic Tip #42: Using marks

 tip karma   Rating 43/22, Viewed by 2471 

Read and edit this tip on the Vim tip wiki. The wiki may have a more recent version of this tip.

created:   March 9, 2001 2:20      complexity:   basic
author:   Anonymous      as of Vim:   5.7

To mark one or more positions in a file, use the m[ark] command.

Examples:

ma       -    set current cursor location as mark a

'a       -    jump to beginning of line of mark a

`a       -    jump to postition of mark a

d'a      -    delete from current line to line of mark a

d`a      -    delete from current cursor position to mark a

c'a      -    change text from current line to line of mark a

y`a      -    yank text to unnamed buffer from cursor to mark a

:marks   -    list all the current marks

NB: Lowercase marks (a-z) are valid within one file. Uppercase marks
(A-Z), also called file marks, are valid between files.

For a detailed description of the m[ark] command refer to

:help mark

See also:

:help various-motions

 rate this tip  Life Changing Helpful Unfulfilling 

<< Command-history facilities for Oracle/sqlplus user | Using abbreviations >>

Additional Notes

[email protected], December 10, 2001 14:41
I find that the most useful command is '' (that's a pair of single quotes).  This jumps to the special mark ' which is set automatically after every jump.  This allows you to easily return to your starting point after a search, for example.  This is similar to using the jump stack (vimtip #10 or :help jump-motions).
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
   
Sponsored by Web Concept Group Inc. SourceForge.net Logo