打开新的终端窗口时,最近要写入的 VIM 撤消文件显示为第一行,通常会出现某种形式的错误。 为什么会出现这种情况,有什么方法可以阻止它吗?将 .hushlogin
添加到我的主目录不起作用。
上下文: 我的 .dotfiles
在 Git 存储库中进行版本控制,包含符号链接(symbolic link)的 .Vim
目录。我正在使用 ZSH、iTerm2
和 Git
的自制安装。
消息: /Users/joshuaberk/.dotfiles/vim/vim.symlink/undo/%Users%joshuaberk%.dotfiles%system%env.zsh:1:不匹配
我的 .Vimrc
的(可能相关的)部分包含在下面(撤消文件设置位于“备份”中)。
" Search/Substitution/Completion
set ignorecase " removes case sensitivity by default
set smartcase " adding ≥1 uppercase = case sensitivity
set incsearch " do incremental searching
set gdefault " substitute all matches in line (not first)
set showmatch " quickly jump to matching bracket
set completeopt=menu,longest " disable preview window on completion
set wildmenu
set wildmode=list:longest,full
" Backup
set undofile
set undodir=~/.vim/undo
set backupdir=~/.vim/backups
set directory=~/.vim/swaps
set history=50
set autoread " updates VIM file if changed elsewhere
set hidden " hide buffers instead of closing them
set clipboard+=unnamed " system clipboard by default
最佳答案
在评论中,您说您正在使用 Zach Holman's dotfiles 。在 zsh
点文件中,there's a section that looks for all *.zsh
files and loads them 。它正在寻找 $ZSH
下的所有内容:
config_files=($ZSH/**/*.zsh)
默认情况下,这是整个 dotfiles 目录:
export ZSH=$HOME/.dotfiles
并且您的 .vimrc
正在将撤消文件设置为 .vim
(这是指向该 dotfiles 目录的符号链接(symbolic link))。
您可以通过删除所有这些撤消文件来解决此问题:
cd ~/.vim/undo
rm *.zsh
但是如何永久修复它呢?我找不到任何特别令人满意的方法。您无法自定义 Vim 使用的撤消文件的名称,但可以自定义其位置。也许你会告诉 Vim 将其撤消保存在 .dotfiles
目录之外:
set undodir=/tmp/vim/undo
if !isdirectory(expand(&undodir))
call mkdir(expand(&undodir), "p")
endif
您可以告诉 Vim 不要保存 .zsh
文件的撤消文件:
autocmd FileType zsh set noundofile
或者,您可以通过更改 .zshrc
将错误消息打印到 /dev/null
来告诉 zsh 到 STFU 有关配置文件中的错误:
for file in ${(M)config_files:#*/path.zsh}
do
source $file 2> /dev/null
done
这似乎是最糟糕的选择;如果您在其他 .zsh
文件之一中引入拼写错误,那么您的生活将会变得一团糟。我会选择选项 1 或 2,具体取决于您希望在重新启动后保留撤消历史记录的程度。
关于VIM 撤消文件在终端登录时显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24253732/