Saving a file with :w takes several seconds for me, and I can't figure out the culprit. This is my .vimrc

" Specify a directory for plugins
" - For Neovim: ~/.local/share/nvim/plugged
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')

  Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
  Plug 'lifepillar/vim-solarized8'

" Initialize plugin system
call plug#end()

"      Settings      "
set nocompatible                " Enables us Vim specific features
filetype off                    " Reset filetype detection first ...
filetype plugin indent on       " ... and enable filetype detection
set ttyfast                     " Indicate fast terminal conn for faster redraw
set ttymouse=xterm2             " Indicate terminal type for mouse codes
set ttyscroll=3                 " Speedup scrolling
set laststatus=2                " Show status line always
set encoding=utf-8              " Set default encoding to UTF-8
set autoread                    " Automatically read changed files
set autoindent                  " Enabile Autoindent
set backspace=indent,eol,start  " Makes backspace key more powerful.
set incsearch                   " Shows the match while typing
set hlsearch                    " Highlight found searches

set noerrorbells                " No beeps
set number                      " Show line numbers
set showcmd                     " Show me what I'm typing
set noswapfile                  " Don't use swapfile
set nobackup                    " Don't create annoying backup files
set splitright                  " Vertical windows should be split to right
set splitbelow                  " Horizontal windows should split to bottom
set autowrite                   " Automatically save before :next, :make etc.
                " Don't need to write before calling :GoBuild!
set hidden                      " Buffer should still exist if window is closed
set fileformats=unix,dos,mac    " Prefer Unix over Windows over OS 9 formats
set noshowmatch                 " Do not show matching brackets by flickering
set noshowmode                  " We show the mode with airline or lightline
set ignorecase                  " Search case insensitive...
set smartcase                   " ... but not it begins with upper case
set completeopt=menu,menuone    " Show popup menu, even if there is one entry
set pumheight=10                " Completion window max size
set nocursorcolumn              " Do not highlight column (speeds up highlighting)
set nocursorline                " Do not highlight cursor (speeds up highlighting)
set lazyredraw                  " Wait to redraw

set belloff=all

" Strips trailing whitespace
autocmd BufWritePre * %s/\s\+$//e

" Clears search buffer with ,/
nmap <silent> ,/ :nohlsearch<CR>
" Turn off search highlight
nnoremap <leader><space> :nohlsearch<CR>

" Enable to copy to clipboard for operations like yank, delete, change and put
" http://stackoverflow.com/questions/20186975/vim-mac-how-to-copy-to-clipboard-without-pbcopy
if has('unnamedplus')
  set clipboard^=unnamed
  set clipboard^=unnamedplus
  set clipboard=unnamed

" Colorscheme
let g:solarized_use16 = 1
set background=light
colorscheme solarized8

"      Mappings      "

" Set leader shortcut to a comma ','. By default it's the backslash
let mapleader = " "

" Search mappings: These will make it so that going to the next one in a
" search will center on the line it's found in.
nnoremap n nzzzv
nnoremap N Nzzzv

" Act like D and C
nnoremap Y y$

" Settings: Mouse & Scrolling
set mouse=a
nnoremap <2-LeftMouse> <nop>
inoremap <2-LeftMouse> <nop>
vnoremap <2-LeftMouse> <nop>
nnoremap <ScrollWheelUp> <C-y>
nnoremap <ScrollWheelDown> <C-e>
nnoremap <Up> <C-y>
nnoremap <Down> <C-e>

"      Plugins      "

" vim-go
let g:go_fmt_command = "goimports"
let g:go_def_mode='gopls'

What can I do to speed this up?

  • 1
    Any file? Or can you provide a specific example? One guess might be the autocommand isnt grouped and so might be getting triggered multiple times. – D. Ben Knoble Jun 19 '19 at 2:46
  • 2
    Firstly you should follow the answer to this question that should give you an idea of what is going wrong. Then if you don't find the culprit by yourself or find the problem but don't know how to fix this you can edit your question to give us more details about your problem. – statox Jun 19 '19 at 7:17
  • 3
    Are you saving a Go file by chance? If it takes a while then it's probably vim-go running goimports and/or a Go linter. See if disabling vim-go helps. – Martin Tournoij Jun 19 '19 at 10:51
  • 4
    Try if :noa :w works faster. If it does, inspect the au BufWritePost and au BufWritePre autocommands – Christian Brabandt Jun 19 '19 at 12:06
  • 2
    @ChristianBrabandt I didn't know about :h :noautocmd that's a very cool command! – statox Jun 19 '19 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.