English 中文(简体)
Vim 创纪录历史
原标题:Vim record history
  • 时间:2012-05-25 10:34:08
  •  标签:
  • vim

Vim stores the list of commands that we applied using : for the current execution. But when I close vim and start it again, the vim command history is lost. I tried set history = 1000 in the .vimrc file but that did not help.
Where does Vim maintain the local command history?
What is the command to retain command history?

最佳回答

要检查 Vim 是否支持 viminfo 文件( 保存历史), < code>: echo has ( viminfo) 。 相应的设置不能是空的 : < code>: set viminfo? 和 < code>: set历史? 应该大于一个 。

如果在撰写 viminfo 文件时出现问题( 虽然 Vim 在此情况下应该投诉 Vim), 您可以通过 < code> vim - i/ tmp/ viminfo 尝试通过另一个地方

问题回答

只是前几天我发现的一个问题, 这可能不是你的问题:

在一些 Linux 系统( 如 Ubuntu) 中, 如果您第一次运行 VIM 系统, 您作为超级用户运行, 那么$HOME/. viminfo 文件会与根所有者一起创建, 而您的本地用户没有写入权限 。 这解释了为什么我的 VIM 没有保存命令历史, 当它被正确配置时 。

底线: 在 *nix 系统中, 定位您的. viminfo 文件, 并确保您有读/ 写权限 。

您应该检查 < code>. viminfo 文件的权限。 您可能需要使用 < code> chown 或 < code>sudo chown 将文件所有者更改为当前用户 。

班特先生已经给出答案了

  • Go to $HOME directory.
  • give ls -l .viminfo to check permissions.
  • change permission so that group and owner also can have write permission. use:

     sudo chown yourUserId $HOME/.viminfo
    

它应该解决这个问题。

您必须设置 viminfo 选项。 设置在您的 $MYVIMC 中

< 强度 > 更新 < / 强度 > 以找出选项上次设置/ 修改的位置 :

:verbose set viminfo?

http://vimdoc.sourceforge.net/htmldoc/starting.html#viminfo-file' rel=“no follow'>http://vimdoc.sourceforge.net/htmldoc/starting.html#viminfo-file

If you exit Vim and later start it again, you would normally lose a lot of information. The viminfo file can be used to remember that information, which enables you to continue where you left off.

这是在用户手册第21.3节中介绍的。

viminfo 文件用于存储 :

  • The command line history.
  • The search string history.
  • The input-line history.
  • Contents of non-empty registers.
  • Marks for several files.
  • File marks, pointing to locations in files.
  • Last search/substitute pattern (for n and & ).
  • The buffer list.
  • Global variables.

The viminfo file is not supported when the |+viminfo| feature has been disabled at compile time.

您也可以使用 < a href=>" "http://vimdoc.sourceforge.net/htmldoc/ starting.html#session" rel="nofollow"\ code>session 文件。

我在Ubuntu上绕圈圈圈圈, 并设定上面建议的 Viminfo 解决方案, 导致错误 。

I eventually did the command "version" in the command mode and it came back with "-" for most stuff including: -cmdline_hist -cmdline_info

I ran the following command and it all worked fine again: sudo apt install vim

我也有同样的问题。 问题是我安装了“ 坚固的” vim- minimal ( 这是Fedora 的默认), 它不支持历史。 我不得不卸载它, 并安装完整的“ 坚固的 > vim < / strong > 。 我现在有历史... 和通俗的颜色 。

如果您正在使用 Vimrc 文件, 请检查您的文件夹和文件是否存在和正确

set history=200 
set undolevels=128 
set undodir=~/.vim/undodir/ 
set undofile 
set undolevels=1000 
set undoreload=10000 

如果指定的文件夹( 我情况下的 undodir ) 不存在, 历史将不会被保存 。





相关问题
Autoupdate VIM Plugins?

Is it possible to update vim plugins automatically?

how to unindent in vim without leaving edit mode?

I m writing a lot of python code recently, and i used the tab-to-space mode in vim. I was just wondering how would i unindent in vim without leaving edit mode for example after i finished if...: block....

Scrolling inside Vim in Mac s Terminal

I ve been googling around trying to figure out if it s possible to use my mouse wheel to scroll while inside Vim in Mac s Terminal, with no luck. It seems as if only X11 or iTerm support this. Before ...

Vim - Deleting XML Comments

How do I delete comments in XML? If the opening and the closing comment tags are on the same line, I use :g/^<!--.*-->$/d to delete the comment. How to delete the comments that are spread ...

Limiting a match in vim to certain filetypes?

I have the following in my .vimrc to highlight lines longer than 80 chars: highlight OverLength ctermbg=red ctermfg=white guibg=#592929 match OverLength /\%81v.*/ This works quite well. However, the ...

Profiling Vim startup time

I’ve got a lot of plugins enabled when using Vim – I have collected plugins over the years. I’m a bit fed up with how long Vim takes to start now, so I’d like to profile its startup and see which of ...

热门标签