Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm using a lot of plugins -- perhaps one of them is the culprit. Here is my .vimrc, if anyone is interested:

" 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
share|improve this question
2  
Does it happen when you remove your .vimrc? Try removing everything, then adding stuff back. Once you find the config setting causing the problem, research that. –  Zoredache Feb 13 '13 at 17:27
1  
Turns out it was the following line in my .vimrc: set foldmethod=syntax According to vim's help (:help foldmethod), the syntax setting caused vim to use syntax highlighting to determine how to automatically fold my code. It must have been parsing syntax for the entire file every time I entered a character. For what it's worth, Zoredache's suggestion of removing everything in my .vimrc file and then adding things back one-by-one helped me find the problem. –  fireballmage Feb 14 '13 at 0:27
    
Tou should add that as an answer. –  Zoredache Feb 14 '13 at 1:05
    
Yerps -- I'm just a new user so it didn't let me answer my own question until 15 hours later or something... –  fireballmage Feb 14 '13 at 23:59
1  
Per @Zoredache's suggestion: opening Vim with -u "NONE" is a quick way to try something using the default config. –  Nathan Long May 10 '13 at 10:48

2 Answers 2

I had a similar problem and made the plugin

https://github.com/Konfekt/FastFold

that updates the folds in your currently edited buffer by your preferred foldmethod when saving the buffer, and keeps them as is otherwise (by keeping the foldmethod set to manual).

share|improve this answer
    
That looks really useful; thank you for sharing! –  fireballmage 3 hours ago
up vote 8 down vote accepted

Turns out it was the following line in my .vimrc:

set foldmethod=syntax

According to vim's help (:help foldmethod), the syntax setting caused vim to use syntax highlighting to determine how to automatically fold my code. It must have been parsing syntax for the entire file every time I entered a character.

For what it's worth, Zoredache's suggestion of removing everything in my .vimrc file and then adding things back one-by-one helped me to find the problem.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.