John
John

Reputation: 1276

Where to locate vim undo settings and how to turn them off?

I'm having a lot of trouble with vim undo. I have 'set noundofile' in my ~/.vimrc and attached is a screen shot of my working dir's, it is super annoying having all the .un~ files all over the place. little help here thanks!

screen shot of a dir

Below is my .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>

Upvotes: 1

Views: 2544

Answers (3)

CactusCoder
CactusCoder

Reputation: 1

Note that the undofile feature was implemented in Vim version 7.3. If you are using an earlier version and include set undofile or set noundofile in your .vimrc, you will get an error like this:

E518: Unknown option: noundofile

Ideas for checking the version of Vim to prevent these errors can be found here.

Upvotes: 0

FDinoff
FDinoff

Reputation: 31429

I personally like the persistent undo feature. However you can change where the undofiles are located by setting undodir.

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

If you do this you must make sure $HOME/.vim/vimundo exists first by running

mkdir -p $HOME/.vim/vimundo

(You still have to delete the old ones but at least they aren't cluttering up the working directory anymore)


You can also do the same with backup files if you want. (:h backupdir)


Other notes about your vimrc.

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

The set runtimepath^=~/.vim/bundle/ctrlp.vim shouldn't be needed because pathogen should have already appended it to the runtimepath.

And as @romainl says filetype plugin on is redundant.

Upvotes: 8

romainl
romainl

Reputation: 196556

From :help 'undofile':

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

so…

  1. you don't need to set noundofile because it is off by default,

  2. you will need to remove all those file by yourself.

Upvotes: 3

Related Questions