brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: Vim's :browse oldfiles reopens a file you edited recently

Vim
~/tips/tip-vim-browse-oldfiles

:browse oldfiles

Picks a recently edited file from a numbered list.

Vim remembers which files you edited. When you want to get back to a file from yesterday and can’t remember its path, I’d let Vim show the list.

:browse oldfiles

Vim lists recent files with a number in front, and then asks for a number. Type it, press Enter, and the file opens. Plain :oldfiles prints the same list without the prompt.

The list comes from the viminfo file, ~/.viminfo. The default viminfo setting keeps marks for the last 100 files, which is also how long this list gets. Raise the number if you want more:

set viminfo='500,<50,s10,h

A filter helps on a long list:

:browse filter /nginx/ oldfiles

That only shows paths that contain “nginx”.

You can also start Vim at the last file you edited, with the shell command vim -c "normal '0": the '0 mark is where you were when you last quit Vim.

The list updates when Vim exits, so files you opened in another Vim that is still running won’t be there yet. And if viminfo is switched off, for example with -i NONE, there is no list at all.

Further reading: Vim help: :oldfiles, Vim help: :browse

Going deeper: Guide: advanced tmux, a config that grows with you, formats, layouts and more

More Vim tips :%s/<Ctrl-r><Ctrl-w>/newname/g /oldname find . -name "*.conf" | vim – vim --clean file.txt :set textwidth=72 All Vim tips (45) All topics

Link