How do I reopen Vim and jump directly to where I was editing last time?
Answer
'0
Explanation
Pressing '0 in normal mode jumps to the exact cursor position in the most recently edited file, even after closing and reopening Vim. Vim persists this information in the viminfo file (Neovim: shada), so your editing position survives across sessions — no plugins required.
How it works
'is the "jump to mark" command0is a special file mark automatically maintained by Vim/Neovim — it always points to the cursor position in the last file you edited before quitting- Marks
'1through'9track the 9 most recently edited files in order, giving you a session history you can navigate
Example
You're deep in internal/server/handlers.go at line 312, then close Vim. The next day:
$ vim
'0
Vim opens handlers.go and places your cursor at line 312, column intact.
To browse the full history of recently edited files:
:marks 0123456789
Tips
- If
'0doesn't work, ensure yourviminfois configured to save file marks::set viminfo+=f1 - Neovim users: the equivalent setting is
:set shada+=f1 - In your shell,
vim -c "normal '0"opens Vim directly at your last position — useful as a shell alias likealias vl='vim -c "normal \x27 0"' - The changelist (
g;) tracks positions within the current session; file marks ('0–'9) track across sessions