Ordinarily, tab (a.k.a. ctrl+i) and ctrl+o traverse the jump list.
Vim supports adding entries to the jump list by setting the '
mark. As such, for your line numbers case, you could set up a jump list with the following:
vim +"12ma '|20ma '|56ma '" file_name
But, then Vim still starts on the file like normal, and at the end of the jumps list. As such, you can use ctrl+o to move back through the list (starting at line 56, then 20, then 12) and tab to go back forward through the list.
As such, it might make sense to construct your list in reverse, so that your first ctrl+o gets you to the first entry you want.
Downsides:
- Jump operations (described in
:help jump-motions
) will move you to the end of the jumps list and add another entry, making it a bit interesting to then navigate to your saved entries.
- The backwards/forwards nature of this can be confusing
I tried doing stuff to start the session at the beginning of the set of jumps, with stuff like
vim +"12ma '|20ma '|56ma '|norm 3^O" file_name
but they don't work unless I prevent my vimrc from running. I think I must have a plugin or something trying to be "nice" by moving my cursor around (probably that common snippet that places your cursor where you left it last on BufReadPost), so the following actually works, so long as you don't jump before you want to use tab to get to the next line:
vim -u None +"12ma '|20ma '|56ma '|norm 3^O" file_name
where the 3
is however many items you put on the jump list and ^O
is a literal control+o (typed like ctrl+vcrtl+o).
Downsides:
- Harder to type (but if it is constructed by a program, probably not bad)
- Might not be able to use your default vimrc (though, again, if you are running via a program, this is probably an advantage)
vim +7 file_name
orvim -c7 file_name
, it will openfile_name
and position the cursor on line 7. If you typevim +'/pattern' file_name
orvim -c '/pattern' file_name
it will openfile_name
and position the cursor on the first line wherepattern
is found. From there if you hitn
, you will reach the other matches. However, I did not understand your second question concerning the tab sequence and Tab key, sorry.myedits.vim
, where each line is an Ex command, and then from the shell typevim +'so myedits.vim' file_name
. If it's what you want, you could be interested in this: vi.stackexchange.com/a/5990/4939 Otherwise, could you provide more info on your end goal?]z
? Or by putting the sections into the quickfix list or the location list withvimgrep
and mapping tab to:cn
or:ln
vim "+call cursor(8, 16)" myfile.txt
to jump to line 8, column 16. (I use this when launching Vim from other editors/debuggers.)