【问题标题】:Where to locate vim undo settings and how to turn them off?在哪里可以找到 vim 撤消设置以及如何关闭它们?
【发布时间】:2013-08-30 09:54:36
【问题描述】:

我在使用 vim undo 时遇到了很多麻烦。我在我的 ~/.vimrc 中设置了 'set noundofile' 并附上了我的工作目录的屏幕截图,所有的 .un~ 文件到处都是非常烦人的。有点帮助,谢谢!

下面是我的.vimrc

set nocompatible
exec pathogen#infect()
filetype plugin indent on
filetype plugin on
"syntax enable
syntax on
set background=light
set noundofile
let g:solarized_termtrans = 1
colorscheme solarized
set number
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
vnoremap < <gv
vnoremap > >gv
set runtimepath^=~/.vim/bundle/ctrlp.vim
autocmd FileType ruby set ft=ruby.rails
autocmd Filetype ruby setlocal ts=2 sts=2 sw=2
set nobackup      " no backup files
set nowritebackup " only in case you don't want a backup file while editing
set noswapfile    " no swap files
set clipboard=unnamed " use Mac clipboard for yank/paste/etc.
" expand %% to file dir
cnoremap %% <C-R>=expand('%:h').'/'<cr> 

set autoindent    " always set autoindenting on
set copyindent    " copy the previous indentation on autoindenting
set shiftround    " use multiple of shiftwidth when indenting with '<' and '>'
set smarttab      " insert tabs on the start of a line according to
                  "    shiftwidth, not tabstop
set ts=2 sts=2 sw=2 expandtab "set two spaces by default

autocmd Filetype javascript setlocal et ts=2 sts=2 sw=2
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS

autocmd Filetype html setlocal et ts=2 sts=2 sw=2
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags

autocmd Filetype css setlocal et ts=2 sts=2 sw=2
autocmd FileType css set omnifunc=csscomplete#CompleteCSS


au BufRead,BufNewFile *.hamlc set ft=haml

" Vim-pasta Settings
let g:pasta_disabled_filetypes = ['python', 'coffee', 'yaml']


" Indent Guide Settings
autocmd FileType html,css,ruby,eruby,javascript,php,xml,haml call indent_guides#enable()
set mouse=a
imap <C-l> <Space>=><Space>
"Make hashrocket with control-l
nmap <silent> <Leader>q :NERDTreeToggle<CR>

【问题讨论】:

  • When 'undofile' is turned off the undo file is NOT deleted.你可以手动删除那些un~文件,并测试它们是否仍然由vim生成。
  • 你不需要filetype plugin on,因为上面的行已经完成了。
  • 我有点困惑,为什么只用一个简单的ls 命令就可以看到这些文件。 Unix 系统通常会隐藏名称以“.”开头的文件,至少在默认设置下是这样。
  • @kent +1 romainl +1 我在我的 .bash_profile 中将 ls 别名为“alias ls='ls -FGaw'”,这对我查看所有内容很有用
  • 我对@9​​87654326@ 的评论是“离题”。

标签: vim


【解决方案1】:

请注意,撤销文件功能是在 Vim 7.3 版中实现的。如果您使用的是早期版本并在 .vimrc 中包含 set undofileset noundofile,您将收到如下错误:

E518: Unknown option: noundofile

可以在here找到检查Vim版本以防止这些错误的想法。

【讨论】:

    【解决方案2】:

    我个人喜欢持久撤消功能。但是,您可以通过设置undodir 来更改撤消文件的位置。

    set undofile
    set undodir=$HOME/.vim/vimundo
    

    如果你这样做,你必须首先通过运行确保$HOME/.vim/vimundo存在

    mkdir -p $HOME/.vim/vimundo
    

    (您仍然需要删除旧的,但至少它们不会再弄乱工作目录了)


    如果需要,您也可以对备份文件执行相同操作。 (:h backupdir)


    关于你的 vimrc 的其他说明。

    exec pathogen#infect()
    ...
    set runtimepath^=~/.vim/bundle/ctrlp.vim
    

    应该不需要set runtimepath^=~/.vim/bundle/ctrlp.vim,因为病原体应该已经将它附加到运行时路径。

    正如@romainl 所说,filetype plugin on 是多余的。

    【讨论】:

    • 非常感谢您关于 undofile 的 cmets,重新设置 ctrlp.vim 嗯,对此不太确定,kien.github.io/ctrlp.vim/#installation 的说明反映了我的安装方式,我错过了什么吗?
    • @John 如果您按照这些说明进行操作, ctrlp.vim 是一个文件夹(显然是……我的错误)。那么这条线是没有意义的,因为病原体已经将它添加到你的运行时路径中。 (尝试删除该行,看看它是否仍然有效)(您也可以通过 :set runtimepath 来检查它是否在运行时路径中)
    • 尽管我喜欢那个插件,但说明中的第二步完全是白痴。
    【解决方案3】:

    来自:help 'undofile'

    boolean (default off)
    […]
    When 'undofile' is turned off the undo file is NOT deleted.
    

    所以……

    1. 你不需要set noundofile,因为它默认是关闭的,

    2. 您需要自己删除所有这些文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-10-22
      • 2022-10-25
      • 2022-06-11
      • 1970-01-01
      • 1970-01-01
      • 2013-01-29
      • 2010-09-16
      相关资源
      最近更新 更多