31

On other distros I have run, vim remembers your command history even between sessions; this is especially handy when doing a lot of similar operations on different files.

For some reason, it has been flushing in Ubuntu 12.04, and I can't figure out why. Here is my :set info:

:set
--- Options ---
  background=dark     helplang=en         history=1000      nomodeline   scroll=27           showmatch           ttyfast
  expandtab           hidden              incsearch           ruler      showcmd             softtabstop=4       ttymouse=xterm2
  backspace=indent,eol,start
  fileencoding=utf-8
  fileencodings=ucs-bom,utf-8,default,latin1
  printoptions=paper:letter
  runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim73,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after
  suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc

1 Answer 1

51

Check presence and rights for ~/.viminfo. Usually that's it which keeps command history, file editing positions, etc. One possible case is that this file belongs to root.

5
  • 1
    It exists, but shows MYUSER:MYUSER; even so, it said permission denied when I tried to open it. Also, there is a ~/.viminfo.tmp
    – Bryan Agee
    Jul 14, 2012 at 6:53
  • 1
    So, I closed all instances of Vim, sudo rm'd both of the above files, and viola--good to go. Thank you!
    – Bryan Agee
    Jul 14, 2012 at 7:00
  • 2
    In my case, my .viminfo has around 1500 search history results.. but when I do q: to bring up the previous search history it only shows 700 or so searches. I keep some search history in the vim search history.. so I can just repeat them when needed. Any idea why this all the search history is not showing up in q: window?
    – alpha_989
    May 31, 2018 at 18:53
  • 1
    It just happened to me after Ubuntu upgrade from 18.04 to 18.10: ~/.viminfo was owned by root and there was ~/.viminfo.tmp owned by user. So I fixed it by: sudo mv ~/.viminfo.tmp ~/.viminfo. Jan 22, 2019 at 10:08
  • It does'nt works for me on my raspbian, my guess is, that could be something with the arrow keys. Apr 19, 2022 at 10:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .