Minha cópia do vim está sendo executada de maneira extremamente lenta quando edito arquivos de médio a grande porte (por exemplo, 1.000 linhas). Como posso acelerar isso?

5

Estou usando muitos plugins - talvez um deles seja o culpado. Aqui está o meu .vimrc, se alguém estiver interessado:

" Character encoding (if this is not set, all manner of hell breaks loose when
" LC_CYTPE is set to anything unexpected.)
set encoding=utf-8

" Pre-plugin stuff
let g:Powerline_symbols = 'fancy' " Awesome forward-facing arrows for powerline

" let g:ctrlp_cmd = 'CtrlPMixed'
let g:ctrlp_switch_buffer = 2
let g:ctrlp_reuse_window = 'netrw\|help\|quickfix'
let g:ctrlp_clear_cache_on_exit = 1 " retain cache on exit (might mean I have to manually refresh every now and again)
let g:ctrlp_open_new_file = 't' " <c-y> opens file in new tab
let g:ctrlp_arg_map = 0 " for <c-z> and <c-o>
let g:ctrlp_extensions = ['tag', 'buffertag', 'quickfix', 'dir', 'rtscript', 'undo', 'line', 'changes', 'mixed', 'bookmarkdir']
let g:ctrlp_root_markers = ['Gemfile', 'README']

" Load vim plugins using vundle!
set rtp+=~/.vim/bundle/vundle
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'mileszs/ack.vim'
Bundle 'kien/ctrlp.vim'
Bundle 'msanders/snipmate.vim'
Bundle 'majutsushi/tagbar'
Bundle 'altercation/vim-colors-solarized'
Bundle 'tpope/vim-commentary'
Bundle 'tpope/vim-endwise'
Bundle 'tpope/vim-eunuch'
Bundle 'tpope/vim-fugitive'
Bundle 'tpope/vim-markdown'
Bundle 'lokaltog/vim-powerline'
Bundle 'vim-ruby/vim-ruby'
Bundle 'SuperTab'
Bundle 'sjl/vitality.vim'
Bundle 'Syntastic'

set wildignore+=doc*,*.png,*.jpg,*.bmp,*.gif,*.jpeg

" enhance command line completion
set wildmenu

" make my leader the comma
let mapleader = ","

" we're running vim, not vi
set nocompatible

" enable per-directory .vimrc files and disable unsafe commands in them
set exrc
set secure

" folding stuff
set foldmethod=syntax
set foldcolumn=3
set foldlevelstart=99

" use exuberant ctags
let g:tagbar_ctags_bin = '/usr/local/bin/ctags'
let g:tagbar_compact = 1
map <leader>b :TagbarOpenAutoClose<CR>
set t_Co=256

" optimize for fast terminal connections
set ttyfast

" don't add empty newlines at the end of files
set binary
set noeol

set mouse=a
set expandtab
set tabstop=2
set shiftwidth=2
set autoindent
set smartindent
set autochdir
set showmode

" show the cursor position
set ruler

" show the (partial) command as it's being typed
set showcmd

" line numbers
set number

" start scrolling three lines before the horizontal window border
set scrolloff=3

" always show the status line
set laststatus=2

" make backspace delete over line brakes, auto indentation, and the place where insert mode began
set backspace=2

set switchbuf+=usetab

" Don't reset cursor to the start of the line when moving around
set nostartofline

" search stuff
set incsearch " highlight dynamically as pattern is typed
set ignorecase " ignore case of searches
set gdefault " adds the global flag to search/replace by default
set hlsearch " highlight search results

" use mac os clipboard as default paste register
" set clipboard=unnamed

" allow cursor beyond last character
set virtualedit=onemore

" history
set history=1000

" syntax stuff
syntax on " highlighting please

" Syntax coloring
set background=dark
let g:solarized_termcolors = 256
let g:solarized_termtrans = 1
colorscheme solarized

" Highlight current line
set cursorline
hi cursorline guibg=#333333
hi CursorColumn guibg=#333333

" don't show the intro message when starting vim
set shortmess=atI

" show the filename in the window titlebar
set title

" respect modeline in files
set modeline
set modelines=4

" disable error bells
set noerrorbells
set visualbell

" Resizing of windows
map + <C-w>+
map _ <C-w>-
map ) <C-w>>
map ( <C-w><
set equalalways

" Create directories if they don't exist
silent execute '!mkdir -p $HOME/.vimbackup'
silent execute '!mkdir -p $HOME/.vimswap'
silent execute '!mkdir -p $HOME/.vimviews'

" Directories for backups
set backup
set backupdir=$HOME/.vimbackup//
set directory=$HOME/.vimswap//
set viewdir=$HOME/.vimviews//
if exists("&undodir")
  set undodir=$HOME/.vimundo//
endif

" make vim save view (state) (folds, cursor, etc) and then load view again.
au BufWinLeave * silent! mkview
au BufWinEnter * silent! loadview

" Use the same symbols as TextMate for tabstops and EOLs
set listchars=tab:▸\ ,eol:¬

" Make 'kj' in insert mode bring you back to edit mode
inoremap kj <Esc>

" Fold / unfold current block of code
map <leader>a za

" gundo
" map <leader>u :GundoToggle<CR> " Graphical representation of the undo tree

" find with Ack, but in current project
function! AckInProject(command, search)
  execute ":".a:command." ".a:search." --nohtml --nosql ".system("git rev-parse --show-toplevel")
endfunction
command! -nargs=1 Projfind call AckInProject('Ack', '<args>')
command! -nargs=1 ProjfindAppend call AckInProject('AckAdd', '<args>')
map <leader>f :Projfind
map <leader>d :ProjfindAppend

" open new windows
map <leader>sl :vsplit<CR><C-W>l
map <leader>sh :vsplit<CR><C-W>h
map <leader>sj :split<CR><C-W>j
map <leader>sJ :split<CR><C-W>jG
map <leader>sk :split<CR>
map <leader>sK :split<CR>gg
map <leader>t :tabnew<CR>

" move between windows
map gj <C-w>j
map gk <C-w>k
map gl <C-w>l
map gh <C-w>h
map g= <C-w>=

" move between tabs
nnoremap <C-h> gT
nnoremap <C-l> gt

" move between quickfix errors
nnoremap <C-j> :cp<CR>
nnoremap <C-k> :cn<CR>

" ON-THE-FLY SETTINGS CHANGING
" Edit .vimrc (this file)
map <leader>sv :sp ~/.vimrc<CR><C-W>_
" Edit .zshrc
map <leader>sz :e ~/.zshrc<CR><C-W>_
map <leader>sr :source ~/.vimrc<CR><C-W>_
map <leader>si :set list!<CR> " Show/hide invisibles
map <leader>ss :set hlsearch!<CR> " Toggle search highlighting

" Vimux stuff
map <Leader>c :PromptVimTmuxCommand<CR>
map <Leader>C :RunLastVimTmuxCommand<CR>
map <Leader>rk :InspectVimTmuxRunner<CR>
map <Leader>rq :CloseVimTmuxRunner<CR>
map <Leader>rx :CloseVimTmuxPanes<CR>
vmap <Leader>rr "vy :call RunVimTmuxCommand(@v . "\n", 0)<CR>
nmap <Leader>rr vip<Leader>rr<CR>

" git
map <Leader>gg :Gstatus<CR>
map <Leader>gc :Gcommit<CR>
map <Leader>gb :Gblame<CR>
map <Leader>gp :Git pull<CR>
map <Leader>gP :Git push<CR>

" indentation in ruby
set cinoptions=:0,p0,t0
set cinwords=if,else,while,do,for,switch,case

" enable filetype detection
filetype on
filetype indent on
filetype plugin on

" commentary filetypes
autocmd FileType ruby set commentstring=#\ %s
autocmd FileType vim set commentstring=\"\ %s

" commenting w/ commentary
map <C-\> \\

" syntastic error checking
let g:syntastic_auto_loc_list=1 " auto open error window when errors are detected
let g:syntastic_check_on_open=1 " check for errors on file open
let g:syntastic_error_symbol='✗'
let g:syntastic_warning_symbol='⚠'
map <leader>e :SyntasticCheck<CR>:Errors<cr><C-w>j

" strip trailing whitespace on save
" autocmd BufWritePre * :%s/\s\+$//e
    
por fireballmage 13.02.2013 / 18:22

2 respostas

9

Acontece que foi a seguinte linha no meu .vimrc:

set foldmethod=syntax

De acordo com a ajuda do vim ( :help foldmethod ), a configuração syntax fez com que o vim usasse o realce de sintaxe para determinar como dobrar meu código automaticamente. Ele deve ter analisado a sintaxe do arquivo inteiro toda vez que eu digitei um caractere.

Por que vale a pena, a sugestão da Zoredache de remover tudo no meu arquivo .vimrc e depois adicionar as coisas uma a uma me ajudou a encontrar o problema.

    
por 15.02.2013 / 00:59
3

Eu tive um problema semelhante e fiz o plugin

link

que atualiza as dobras em seu buffer atualmente editado pelo método de dobra preferido ao salvar o buffer e as mantém como ocorre de outra forma (mantendo o foldmethod definido como manual).

    
por 21.07.2014 / 22:15

Tags