I am experiencing some very painful lag when accessing directories/files over UNC paths using gVim 7.3 on Windows Vista.
It is slow reading/writing files, as well as tab completiong of directory/file names when opening new buffers. I don't notice this lag when using WordPad though.
Things I've tried:
Cream (apparently they had a fix for directory naming schemes)
Mapping the network drive to z: or something else
Various settings
set ffs=dos
set complete=.,w,b,u,t
set noshellslash
I've tried cygwin, but the same noticeable lag appears there as well. I already have all swap/backup files turned off. Any help greatly appreciated... I've dumped my vimrc for reference
if v:progname =~? "evim"
finish
endif
set nocompatible
:runtime! ftplugin/man.vim
set backspace=indent,eol,start
colorscheme torte " murphy
syn on
set ffs=unix,dos
" portable friendly
set nobackup
set nowritebackup
set noswapfile
set viminfo=
" gui options (http://steveno.wordpress.com/2007/10/08/vim-for-windows/)
set guioptions-=T " No toolbar
set gfn=Consolas:h9:cANSI
set history=50
set ruler
set showcmd
set incsearch
set number
set tabstop=4
set softtabstop=4
set shiftwidth=4
set wrap
set wildmode=longest,list,full " Complete longest string, list alternatives
" then completed next full match, cycling back
function! ToggleHLSearch()
if &hls
set nohls
else
set hls
endif
endfunction
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
inoremap <tab> <c-r>=InsertTabWrapper()<CR>
nmap <silent> <C-n> <Esc>:call ToggleHLSearch()<CR>
nmap ,s :source ~/.vimrc<Return>
" change current directory to that of open buffer
nmap ,c :cd %:p:h<Return>
nmap <c-h> <c-w>h<c-w><bar>
nmap <c-l> <c-w>l<c-w><bar>
map <C-J> <C-W>j<C-W>_
map <C-K> <C-W>k<C-W>_
map Q gq
" Commenting blocks of text
" ,< <!-- --> html style comments
map ,< :s/^\(.*\)$/<!-- \1 -->/<CR><Esc>:nohlsearch<CR>
" ,/ // comments
map ,/ :s/^/\/\//<CR>
" ,# # comments
map ,# :s/^/#/<CR>
" uncommenting all of the above
"map ,- :s/^\(\/\/|<!-- |#\)\(.*\)\(-->\)*/\1/<CR>
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
if has("autocmd")
"&& !exists("autocommands_loaded")
let autocommands_loaded = 1
filetype plugin indent on
augroup vimrcEx
au!
" Remove ALL autocommands for the current group.
autocmd!
autocmd FileType text setlocal textwidth=78
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
au BufRead *.html set filetype=html4
augroup END
" allow editing Word Docs sanely
autocmd BufReadPre *.doc set ro
autocmd BufReadPre *.doc set hlsearch!
autocmd BufReadPost *.doc %!antiword "%"
" uncomment the following to remember the view of the file edited between
" sessions
" au BufWinLeave * mkview
" au BufWinEnter * silent loadview
" run file with PHP CLI (CTRL-M)
autocmd FileType php noremap <C-M> :w!<CR>:!/usr/bin/php %<CR>
" parser check (CTRL-L)
autocmd FileType php noremap <C-L> :!/usr/bin/php -l %<CR>
" highlight current line only for current buffer
"autocmd BufLeave * setlocal nocursorline
"autocmd BufEnter * setlocal cursorline
au BufRead,BufNewFile *.tea set filetype=tea
"au! Syntax newlang source $VIM/newlanguage.vim
else
set autoindent
endif
the same thing was driving me insane, but there is a fix I just found.
I really do not know why yet, but the problem goes away when you disable plugin/matchparen.vim plugin (changing vim extension would do the trick).
I will definitely look into it as I use parentheses matching a lot.
See
:he swap-file
You can disable swapfiles with :se noswapfile (caution!) or use the `directory` setting to keep the swapfile on a local disk.
Starting vim with the -n option also disables swapfiles; you might want to combine that with -R for readonly mode
Another solution I found is that mounting a UNC path as a local drive letter and let Vim use the drive-letter based paths only.
e.g., \\some-server\path\to\workdir => Z:\path\to\workdir
This eliminates the lag completely unless you have connection problems.
Related
I use omnicomplete in VIM and my vimrc is like below.
snipping...
" Autocompletion
set completeopt=longest,noselect,menuone
set omnifunc=syntaxcomplete#Complete
autocmd FileType py set omnifunc=python3complete#Complete
But, when I restart vim. omnifunc doesn't work as i set, even value is different from my vimrc settings
I thought my restoring option was problem. However, block below settings.
" Save and load former states
"autocmd BufWinLeave ?* mkview
"autocmd BufWinEnter ?* silent loadview
It still doesn't work...
How can I resolve it?
Appreciate all your help.
EDIT on 2017.11.08 > Here is my full .vimrc file
syntax on
set nocp " no compatibility with VI
set nu " line number
set cursorline " highlight current cursorline
set ruler " display cursor position information at status line
set ic " case insensitive search
set smartcase " don't use ic when there is Capital letter
set hlsearch " hilight search
set incsearch " show search matches as type
set mouse=a " enalbe cursor move with mouse
set ts=4 " size of \t character (tab stop)
set sw=4 " tab size, when use <<, >>
set sts=4 " how many spaces, when type tab (soft tab stop)
set ls=2 " last window's status line option
set expandtab smarttab
set autowrite " Automatically :write before running commands
set autoread " Auto read when a file is changed on disk
set autoindent
set smartindent
set cindent
set vb noeb " visual bell instead of beep
set tm=500 ttm=0 " to leave insert mode without delay
set encoding=utf8
" Autocompletion
set completeopt=longest,noselect,menuone
set omnifunc=syntaxcomplete#Complete
autocmd FileType py set omnifunc=python3complete#Complete
" Cursor shape
let &t_SI = "\e[5 q" " Start Insert mode
let &t_EI = "\e[0 q" " End Insert mode
" Key mapping
nnoremap <F2> :!ctags -R -I --languages=C,C++ --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
nnoremap <F3> :NERDTreeToggle<CR>
nnoremap <F4> :TlistToggle<CR>
nnoremap <F5> <C-w>=
nnoremap Y y$
nnoremap n nzz
nnoremap N Nzz
nnoremap * *zz
nnoremap # #zz
inoremap <C-h> <Left>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-l> <Right>
inoremap <C-b> <C-Left>
inoremap <C-f> <C-Right>
inoremap <C-a> <Esc>I
inoremap <C-e> <End>
inoremap <C-#> <C-x><C-o>
autocmd FileType c,h,cpp,hpp inoremap {<ENTER> {}<Left><ENTER><ENTER><UP><TAB>
" Save and load former states
autocmd BufWinLeave ?* mkview
autocmd BufWinEnter ?* silent loadview
" C/C++ header
function! s:header()
let name = "__".toupper(substitute(expand("%:t"), "\\.", "_", "g"))."__"
exe "norm! i#ifndef ". name "\n#define ". name "\n\n\n\n#endif\t//". name "\ekk"
endfunction
autocmd BufNewFile *.{h,hpp} call <SID>header()
" Python header
function! s:py_init()
exe "norm! i\n\n\ndef main():\npass\n\n\eIif __name__ == \"__main__\":\n\tmain()\n\egg"
endfunction
autocmd BufNewFile *.py call <SID>py_init()
" Plugin settings using Vundle
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'tpope/vim-fugitive'
Plugin 'scrooloose/nerdtree'
Plugin 'taglist-plus'
Plugin 'nanotech/jellybeans.vim'
call vundle#end()
filetype plugin indent on
" airline settings
set laststatus=2
let g:airline#extensions#tabline#enabled=1 " turn on buffer list
let g:airline_theme='murmur'
let g:airline_powerline_fonts=1
let g:airline#extensions#branch#enabled=1
" NERDTree settings
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
let g:NERDTreeDirArrowExpandable='+'
let g:NERDTreeDirArrowCollapsible='~'
" taglist settings
let Tlist_Use_Right_Window=1
" Color settings with bundle theme (type help highlight in order to see color list)
if has("gui_running")
colo industry " industry, torte, koehler
else
colo slate " slate, koehler, ron, elflord, pablo
endif
colo jellybeans
highlight linenr ctermfg=brown ctermbg=NONE
highlight cursorlinenr ctermfg=green ctermbg=NONE
highlight cursorline cterm=underline
You can find out where an option was last set via
:verbose set omnifunc?
It looks like your problem is caused by a wrong filetype in your :autocmd. Though Python files usually have a *.py extension, the filetype in Vim is named python. So, this should work:
autocmd FileType python set omnifunc=python3complete#Complete
Additional critique
I would recommend putting the settings and mappings into ~/.vim/after/ftplugin/python.vim instead of defining lots of :autocmd FileType python; it's cleaner and scales better; requires that you have :filetype plugin on, though.
By using :set, the value of 'omnifunc' will be inherited by other buffers that are opened from a Python one (e.g. via :new). Usually, this is not what you want. Use :setlocal omnifunc=... instead.
I used the following to make saving saving faster in Vim:
nnoremap <leader>w :w!<cr>
inoremap <leader>w <esc>:w!<cr>
Something strange happens with the first one, though, each time I save there is like a 2-second delay. I think this is strange since it is set as nnoremap and there isn't another mapping pointing to w.
What could be the problem?
My .virmc:
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Maintainer: Alexandro Chen
" Website: http://alexandrochen.com
" Version: 0.1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Basic
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sets how many lines of history VIM has to remember
set history=700
filetype plugin on
filetype indent on
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Appareance
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
syntax enable
colorscheme molokai
set guifont=Droid\ Sans\ Mono\ 10
set encoding=utf8
set number
set ruler
set magic
set nolazyredraw
set showmatch
" Sets initial window size
set lines=40 columns=160
set softtabstop=2
set shiftwidth=2
set tabstop=2
set expandtab
set guioptions-=r " Disable right scrollbar
set guioptions-=R
set guioptions-=l " Disable left scrollbar
set guioptions-=L
set t_Co=256
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Mapping
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let mapleader = ","
nnoremap <leader>w :w!<cr>
inoremap <leader>w <esc>:w!<cr>
nnoremap <leader>sv :source $MYVIMRC<cr>
nnoremap <leader>ev :split $MYVIMRC<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Files
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nobackup
set nowb
set noswapfile
autocmd FileType ruby,coffeescript autocmd BufWritePre <buffer> :%s/\s\+$//e
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Workarounds
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:session_autoload = 'no'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugins
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" NERDTree
au VimEnter * NERDTree /home/alex/
" Zen Coding
let g:user_zen_expandabbr_key = '<leader>e'
So, when you comment out
inoremap <leader>w <esc>:w!<cr>
you still have a problem with the first one?
Also, :help ttimeoutlen
'ttimeoutlen' 'ttm' number (default -1)
The time in milliseconds that is waited for a key code or mapped
key sequence to complete.
I have set ttimeoutlen=10 in my .vimrc
Also, I've played with save mappings for a while, and finally mapped
save on space bar. Very happy with it.
I think you had better to remove the inoremap <leader>w <esc>:w!<cr>, and add inoremap jk <esc>,everytime you want to save file, you had better to return normal mode and save it.Or when you press ,word, vim will regard ,w to save file.
I tried to ignore the vendor by adding the following setting in .vimrc
and I start my ctrlP by typing ff
map ff :CtrlP<.><cr>
However, it still tried to index all the files under the zeus folder including vendor folder.
But after finishing index, I still can NOT search the files under vendor,
Why does CtrlP take long time to index ?
129 "add ctrlp.vim setting
130 ""
131 set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*/vendor/*,*/\.git/*
132 let g:ctrlp_custom_ignore = 'tmp$\|\.git$\|\.hg$\|\.svn$\|.rvm$|.bundle$\|vendor'
133 let g:ctrlp_working_path_mode = 'ra'
134 let g:ctrlp_match_window_bottom=1
135 let g:ctrlp_max_height=25
136 let g:ctrlp_match_window_reversed=0
137 let g:ctrlp_mruf_max=500
138 let g:ctrlp_follow_symlinks=1
139 let g:ctrlp_clear_cache_on_exit=0
Here is my .vimrc, I thought there might be some settings conflicting each other
hi Comment ctermfg=6
"make vim save and load the folding of the document each time it loads"
""also places the cursor in the last place that it was left."
au BufWinLeave *.* mkview
au BufWinEnter *.* silent loadview
"function SetCafeOptions()
"CoffeeCompile
":set nonu
":res -24
":res +24
"endfunction
set encoding=utf-8
set fileencoding=utf-8
colorscheme elflord
set smartindent
set tabstop=4
set expandtab
set shiftwidth=4
"make it autoreload
set autoread
"auto move it last time the position you viewed
"make vim save and load the folding of the document each time it loads"
""also places the cursor in the last place that it was left."
"try to set show ansi color
if &term=="ansi"
set t_Co=0
endif
"set expandtab
filetype on
if has("cscope")
set csprg=/usr/bin/cscope
set csto=0
set cst
set nocsverb
" add any database in current directory
if filereadable("cscope.out")
cs add cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set csverb
set cscopetag
set cscopequickfix=s-,g-,c-,d-,t-,e-,f-,i-
endif
"let Tlist can close windows at one time
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
let Tlist_Ctags_Cmd = '/usr/local/bin/ctags'
" Key map
" Presee F4 and you can open the NERDTree
nnoremap <silent> <F4> :NERDTree<CR>
"nnoremap <silent> <F3> :!/usr/bin/env python %<CR>
" Show function List with Tlist
nnoremap <F12> :TlistToggle<CR>
" Map ctrl+q to ctrlw+ctrlw
"
"nnoremap <silent> <C-q> :<C-w><C-w>
"switch in splitted window
map <c-d> <c-w>l
map <c-a> <c-w>h
"set highlight
set hlsearch
"set autocomplet
"autocmd BufNewFile,BufRead *.html.erb set filetype=html.eruby
autocmd BufNewFile,BufRead *.html.erb set filetype=erb.html.eruby
filetype plugin indent on
"auto import python template
autocmd bufnewfile *.py 0r ~/common_lib/python_lib/tmpl.py
map ff :CtrlP<.><cr>
"set NerdTreeSize
let g:NERDTreeWinSize=12
let g:NERDTreeIgnore=['\.vim$', '\~$', '\vendor$']
"auto close the nerdtress window whe you open new file
"let g:ctrlp_dont_split = 'nerdtree'
set nocompatible " explictly get out of vi-compatible mode
set background=dark " we plan to use a dark background
syntax on " syntax highlighting on
set number " turn on line numbers
set ruler "always show current position along the bottom
set incsearch " do highlight as you type you search phrase
set ignorecase " case insensitive by default
set smartcase " if there are caps, go case-sensitive
"Rope vim
"let $PYTHONPATH .= ":~/install/ropehg/rope:~/install/ropehg/ropemode:~/install/ropehg/ropevim"
"source ~/install/ropehg/ropevim/ropevim.vim
"let g:pymode_rope_goto_def_newwin = "new"
"let ropevim_vim_completion=1
"Use Ctrl + ] . to autocomple
inoremap <C-]> <C-R>=RopeCodeAssistInsertMode()<CR>
map <leader>j :RopeGotoDefinition<CR>
map <leader>r :RopeRename<CR>
" Load the whole plugin
let g:pymode = 1
" Load run code plugin
let g:pymode_run = 1
"add ctrlp.vim setting
""
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*/vendor/*,*/\.git/*
let g:ctrlp_custom_ignore = 'tmp$\|\.git$\|\.hg$\|\.svn$\|.rvm$|.bundle$\|vendor'
let g:ctrlp_working_path_mode = 0
let g:ctrlp_match_window_bottom=1
let g:ctrlp_max_height=25
let g:ctrlp_match_window_reversed=0
let g:ctrlp_mruf_max=500
let g:ctrlp_follow_symlinks=1
let g:ctrlp_clear_cache_on_exit=0
"Vundle
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'tpope/vim-surround'
Bundle 'Raimondi/delimitMate'
"coffee script"
Bundle 'kchmck/vim-coffee-script'
Bundle 'ack.vim'
Bundle 'matchit.zip'
Bundle 'kien/ctrlp.vim'
"Markdown"
"Bundle 'plasticboy/vim-markdown'
""Vim-scripts repo
"Bundle 'The-NERD-Commenter'
Bundle 'pep8'
""Bundle 'AutoClose'
Bundle 'desert-warm-256'
Bundle 'https://github.com/altercation/vim-colors-solarized.git'
filetype plugin indent on
nmap <leader>a <Esc>:Ack ""
"folding code
nnoremap <space> za
vnoremap <space> zf
" pep8
let g:pep8_map='<leader>8'
"coffee script"
call pathogen#infect()
let Tlist_Use_Right_Window = 1
"autocmd BufEnter * if &filetype == "" | setlocal ft=python | endif
"markdown https://github.com/plasticboy/vim-markdown/wiki"
"let g:vim_markdown_folding_disabled=1
"auto exec ruby and coffee script with F5 , remeber to save file before launching
autocmd FileType python map <leader>p :!python %<cr>
autocmd FileType ruby,rb map <leader>5 :w!<cr>:!ruby %<cr>
autocmd FileType * map <leader>e :qa!<cr>
"set extension .god as a Ruby file"
"au BufNewFile,BufRead *.god set filetype=ruby
"autocmd FileType coffee nmap <F5> :CoffeeCompile<cr>
"autocmd FileType coffee map <F5> :call SetCafeOptions()<cr>
"so ~/.vim/snippets/support_functions.vim
set re=1
autocmd Filetype gitcommit setlocal spell textwidth=72
" enable per-project .vimrc files
set exrc
" " Only execute safe per-project vimrc commands
set secure"
Here are a few tips that should definitely speed up ctrlp :
let g:ctrlp_cache_dir = $HOME . '/.cache/ctrlp'
if executable('ag')
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
endif
In the above example, the first option tells ctrlp to persist the cache in the configured location, so when you launch vim again, it will read from there and load the cache (much faster).
The second option configures ctrlp to use ag (the_silver_searcher) instead of vim's native globpath() apis to search for files, this will drastically improve it's scanning speed, if you don't want to use ag, you can even use plain old grep and it still should be significantly faster. Check :h 'g:ctrlp_user_command' for more details.
As I explained here, if you type :help ctrlp-options and read a bit, you will find:
Note #1: by default, wildignore and g:ctrlp_custom_ignore only
apply when globpath() is used to scan for files, thus these options
do not apply when a command defined with g:ctrlp_user_command is
being used.
Thus, you may need to unlet g:ctrlp_user_command (possibly set to a default command) to actually use wildignore. For instance, in your ~/.vimrc, add:
if exists("g:ctrl_user_command")
unlet g:ctrlp_user_command
endif
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*/vendor/*,*/\.git/*
...
After that, you need to refresh your ctrlp cache: in Vim, press F5 in ctrlp mode, or run :CtrlPClearAllCaches, or remove the cache directory directly in your shell:
rm -r ~/.cache/ctrlp/ # On Linux
As for the indexing part (which seems to be your problem), it should follow your ignore rules. You can check the indexed files in ~/.cache/ctrlp/%path%to%your%project%folder.txt.
Last resort for a quick startup
I tried everything I found in different places to improve the indexing speed of my ctrlp, but nothing helped.
At the end, I settled with this:
let g:ctrlp_clear_cache_on_exit = 0
It keeps the ctrlp cache after you close VIM, so the next start up will be fast. And you can update the cache manually by pressing F5 anytime you need.
Found this bit while looking around the interwebs, and it has made indexing and searching for files instant.
let g:ctrlp_user_command = ['.git/', 'git ls-files --cached --others --exclude-standard %s']
I'm not fully grasping what is happening here, so if anyone has a bit more knowledge to dissect this, I'd love to know what's happening behind the scenes.
If you have ripgrep (rg) installed you can use it with CtrlP. It is much faster than the default file search. This is the incantation you need to make it work:
if executable('rg')
let g:ctrlp_user_command = 'rg %s --files --color=never --glob ""'
let g:ctrlp_use_caching = 0
endif
h/t Elliot Jackson
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!
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>
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.
From :help 'undofile':
boolean (default off)
[…]
When 'undofile' is turned off the undo file is NOT deleted.
so…
you don't need to set noundofile because it is off by default,
you will need to remove all those file by yourself.
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.
I am using Macvim 7.3 snapshot 57. I can't seem to get matchit to work in any of my files.
I press % on an opening tag. It doesn't take me to the closing tag...
My vimrc file:
" Pathogen settings
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
set nocompatible
set number
set ruler
set cursorline
syntax on
" Disable all blinking
set guicursor+=a:blinkon0
" Whitespace stuff
set nowrap
set tabstop=2
set shiftwidth=2
set expandtab
set cindent
set smartindent
set autoindent
set list listchars=tab:\ \ ,trail:·
" Searching
set hlsearch
set incsearch
set ignorecase
set smartcase
" Status bar
set laststatus=2
" Start without the toolbar
set guioptions-=T
" Default gui color scheme
" "color default
" color molokai
color railscasts+
" Command-/ to toggle comments
map <D-/> :TComment<CR>j
" Remember last location in file
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal g'\"" | endif
endif
" Thorfile, Rakefile and Gemfile are Ruby
au BufRead,BufNewFile {Gemfile,Rakefile,Thorfile,config.ru} set ft=ruby
" Open split buffers below instead of above current buffer
set splitbelow
" Session options
let g:session_autoload = 1
let g:session_autosave = 1
" Buffer navigation
map <C-K> <C-W><C-K>
map <C-J> <C-W><C-W>
map <C-H> <C-W><C-H>
map <C-L> <C-W><C-L>
" Rails navigation options
nmap <leader>rc :Rcontroller
nmap <leader>rv :Rview
nmap <leader>rm :Rmodel
" Tab completion
" Also needed for better Rails navigation auto-completion
set wildmode=list:longest,list:full
" Open up side panel left (NERDTree) and right(Tagbar)
" nmap <leader>\ :NERDTreeToggle<CR> :TagbarToggle<CR>
nmap <leader>\ :call ToggleNERDTreeAndTagbar()<CR>
" Allow single click for NERDTree
let NERDTreeMouseMode = 3
let g:NERDTreeWinSize = 30
" autocmd VimEnter * NERDTree
" Tagbar options
let tagbar_singleclick = 1
let g:tagbar_sort = 0
let g:tagbar_width = 30
" autocmd VimEnter * nested TagbarOpen
" The Janus plugin sets this to noequalalways for the Zoominfo plugin
" However, we want to set this to equalalways instead, since we want to
" have equal window height when a new window is opened. i.e. via ctrl+w+s
set equalalways
" Matchit already installed in newer versions of vim.
" Don't need to add this onto pathogen bundle folder. We only need
" to configure it.
" Configure matchit so that it goes from opening tag to closing tag
au FileType html,eruby,rb,css,js,xml runtime! macros/matchit.vim
" Set backup and swp dir. Don't forget to clear tmp dir out once in a while
set backupdir=~/.vim/tmp/backup
set directory=~/.vim/tmp/swp
" Detect if a tab was closed, and ensure that height of main window fills the screen (100% height)
au TabEnter * let &lines = 100
" <leader>\ to open or close NERDTree and Tagbar, under the following conditions:
" 1) Only close both if NERDTree and Tagbar are both opened
" 2) Open both if NERDTree and Tagbar are closed OR if one is already opened
function! ToggleNERDTreeAndTagbar()
let w:jumpbacktohere = 1
" Detect which plugins are open
if exists('t:NERDTreeBufName')
let nerdtree_open = bufwinnr(t:NERDTreeBufName) != -1
else
let nerdtree_open = 0
endif
let tagbar_open = bufwinnr('__Tagbar__') != -1
" Perform the appropriate action
if nerdtree_open && tagbar_open
NERDTreeClose
TagbarClose
elseif nerdtree_open
TagbarOpen
elseif tagbar_open
NERDTree
else
NERDTree
TagbarOpen
endif
" Jump back to the original window
for window in range(1, winnr('$'))
execute window . 'wincmd w'
if exists('w:jumpbacktohere')
unlet w:jumpbacktohere
break
endif
endfor
endfunction
Since Vim comes shipped with matchit plugin, all I needed to do was activate it:
vim ~/.vimrc
Then add the following into your .vimrc:
set nocompatible
filetype plugin on
runtime macros/matchit.vim
This line
runtime macros/matchit.vim
is the standard way of activating matchit and it works on all my machines.
Does matchit work after you type
:runtime macros/matchit.vim
in normal mode ?
The page of the matchit plugin says:
Make sure you have a line like
:filetype plugin on
in your vimrc file. This enables filetype plugins, many of which tell
matchit.vim which matching pairs to use.
FYI: in vim 8 runtime macros/matchit.vim becomes packadd! matchit.
I started having the same issue after I updated some of my vim plugings to the latest version for 7.3.
But when I run
:MatchDebug
it fixes the issue for me.
I had a problem with matchit finding the correct matching brace in C++/C when there were commented braces. The following steps, taken from this forum post written by this guy, solved it for me and also pretty much explained the way the whole thing works:
Create the folder ~/.vim/plugin if it is not already there:
mkdir ~/.vim/plugin
Create a file with the name
~/.vim/plugin/matchit.vim :
vi ~/.vim/plugin/matchit.vim
and the following contents:
runtime macros/matchit.vim
Create the directory ~/.vim/doc if it is not already there:
mkdir ~/.vim/doc
Copy /usr/share/vim/vim73/macros/matchit.txt to ~/.vim/doc/ :
cp /usr/share/vim/vim73/macros/matchit.txt ~/.vim/doc/
Open vi
vi
and execute the following in it:
:helptags ~/.vim/doc
Make sure that your ~/.vimrc includes one of the following:
source $VIMRUNTIME/vimrc_example.vim
or
runtime vimrc_example.vim
or
filetype plugin on
or
filetype plugin indent on
Add the following autocommand in your vimrc:
" make matchit work on C-like filetypes
" c and cpp are already handled by their ftplugin
au Filetype css,javascript
\ let b:match_words = &matchpairs
Restart Vim.
I've had similar problem. I've tried runtime macros/matchit.vim with VIM-provided script and it didn't work.
So I've downloaded this script in version 1.13.2 from http://www.vim.org/scripts/script.php?script_id=39, unzipped it into ~/vimfiles and it works!