gravitas
gravitas

Reputation: 703

vim - How do you save line numbers so you can easily jump to them whenever you want?

Suppose I am working on three functions and I will be jumping back and forth between them. Suppose functions A,B, and C are on lines a, b and c. Is there a way to bind the following (which jump to the line position)

:a  
:b
:c 

to keys during runtime so I can easily jump to these positions. If you play Starcraft this is kind of like binding a selected group of units to your number keys, and then using the number keys to quickly change your selected group (or jump to the designated line, in this case).

Or is there another way of getting a similar result that I am unaware of? I just recently discovered that =% autoformats your tabs within the highlighted brace, so I am pretty new to vim.

Thanks.

Upvotes: 3

Views: 782

Answers (2)

Dan Schnau
Dan Schnau

Reputation: 1535

In Starcraft, you "Hotkey" your guys by pressing Ctrl+1 to tag them, then tap 1 to select them again. In Vim, you "Mark" a place by pressing [m], then [a](or any letter) to mark them, then [`], then [a] to go back to that mark.

So you have hotkeys to 1,2,3,4, etc in SC, but marks are a-z(and probably other characters but I'm not sure) in Vim.

For more technical info try

:help marks

Upvotes: 2

Grammin
Grammin

Reputation: 12205

You want to use marks. They allow you to save your current position in the file to a variable.

Upvotes: 11

Related Questions