Vim's :oldfiles
command shows the last 100 open files. I want to clear this list. How do I do that?
I tried googling for "vim oldfiles clear" but that doesnt return useful results. I also tried googling "vim oldfiles location" but also nothing.
If you use :help oldfiles , you will find the command :browse oldfiles which should do what you want.
The viminfo file is designed to store status information: Command-line and Search pattern history Text in registers Marks for various files The buffer list Global variables Each time you exit Vim it will store this information in a file, the viminfo file.
This command basically lists the contents of the v:oldfiles
variable.
However, emptying the variable is not what you want, because it is by
itself generated from the contents of the .viminfo file.
Please read the help for viminfo
. Vim won't store a list of "recent
files". Those files come from the saved marks. And .viminfo stores a
lot of things. I'm not sure you want to remove all of them, so you need
to edit that portion of file. Editing it, however, can be a difficult
maneuver — if you don't disable auto saving it will overwrite when
quitting.
The best solution to your case, in my opinion, is to change the Vim setting that stores recent file marks to store nothing; and then tell Vim to rewrite the file. This can be achieved by the following commands. Please do this in a newly opened Vim session, ideally, one that you haven't edited a file yet.
:set vi+='0 " save no marks, in other words save 0 recent marks
:wv! " write viminfo file without merging with old information
Reload Vim and your list should be clean. Please read the help for
'vi'
to known more. If you want the recent files list to be always
empty, you may want to configure that option to your will in your
.vimrc. It is also useful to see your current configuration with
:set vi
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With