Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to return to the previous point in VIM

Tags:

vim

in VIM editor as I know there is a command `. to return exactly to where we left in VIM.

But my question is, how to make it automatic, what I mean is, everytime I exits and enter the same file again, it brings me to the point where I left.

I saw my friend's VIM has that behavior but he doesn't know how to do it.

Thanks guys!

like image 815
BobAlmond Avatar asked Dec 30 '11 08:12

BobAlmond


People also ask

How do I go back to a previous position in vim?

Vim makes it easy to navigate previous locations: Ctrl + o navigate to the previous location in the jump list (think o as old) Ctrl + i navigate to the next location in the jump list ( i and o are usually next to each other) g; go to the previous change location.

How do I go to previous in vi?

Press <shift-N> to go back to the previous occurrence of your find term.

What does Ctrl-o do in vim?

In insert mode, Ctrl-o escapes user to do one normal-mode command, and then return to the insert mode. The same effect can be achieved by <ESC> ing to normal mode, doing the single command and then entering back to insert mode.


1 Answers

I use these commands a lot:

CTRL-O Go to [count] Older cursor position in jump list (not a motion command).

CTRL-I Go to [count] newer cursor position in jump list (not a motion command).

ma Set mark a at cursor position (does not move the cursor, this is not a motion command).

'a Jump to the mark a in the current buffer.

gi Insert text in the same position as where Insert mode was stopped last time in the current buffer.

like image 62
kev Avatar answered Nov 16 '22 02:11

kev