Reputation: 8178
In vim, lots of times, I'm working on something, and I need to jump down a bunch of lines (or up) and make a quick edit. How do I then quickly go back to where I was?
Maybe...
`.
or...
`2
Upvotes: 0
Views: 58
Reputation: 1976
You could simply mark your current position with ma
(using register a as an example), do whatever you need to do and then jump back to the mark with `a
.
Upvotes: 1
Reputation: 8178
I ended up doing this
nnoremap t g;zz
vnoremap t g;zz
nnoremap T g,zz
vnoremap T g,zz
So t now moves me back one step in the changelist (changelist, right?), and shift + t moves me forward one step.
The zz helps center the line so it's easier to read.
Upvotes: 0
Reputation: 876
Have you tried two single quotes? I'm not sure if that is exactly what you are looking for or not, but I use it all the time to say go look at the top of the file for an include or something, then '' to jump back to where I was.
http://vim.wikia.com/wiki/Moving_around
'' Return to the line where the cursor was before the latest jump. (Two single quotes.)
Upvotes: 1
Reputation: 34628
I typically do a :split
, edit and then :q
.
It's fast in my setup, because I have the following:
nmap <Bar> <C-w>v
nmap - <C-w>s
map <C-c> :quit<CR>
So I just have to hit -
, edit and then Ctrl+c.
Upvotes: 2