1. 程式人生 > >我的vim配置-2018-5-25

我的vim配置-2018-5-25

vim 基本配置

基本配置檔案

"author: pjzero
"email: pjwhusir@gmail.com

" let backspace can delete
set nocompatible
set backspace=indent,eol,start

" Plugin
call plug#begin('~/.vim/plugged')
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'Valloric/YouCompleteMe'
Plug 'scrooloose/nerdtree' Plug 'flazz/vim-colorschemes' Plug 'jiangmiao/auto-pairs' Plug 'ntpeters/vim-better-whitespace' Plug 'tpope/vim-surround' Plug 'vim-airline/vim-airline' Plug 'w0rp/ale' Plug 'Xuyuanp/nerdtree-git-plugin' Plug 'scrooloose/nerdcommenter' Plug 'tmhedberg/SimpylFold' call plug#end() " ============== "
map keys " ============== let mapleader = ";" nmap <leader>w :w!<cr> nmap <leader>q :q<cr> nmap <leader>wq :wq<cr> nmap <leader>tn :tabnew<cr> nmap <leader>te :tabedit nmap <leader>tc :tabclose<cr> " =>Remove unwanted spaces map <leader>c :%s/\s\+$/
/<cr> " =>Removes highlight of your last search noremap <C-h> :nohl<cr> vnoremap <C-h> :nohl<cr> inoremap <C-h> :nohl<cr> " => code format using google/yapf autocmd FileType python nnoremap <leader>= :0,$!yapf<CR> " ============== " end of map keys " ============== " ============== " plug config " ============== " =>nerdtree config map <C-n> :NERDTreeToggle<cr> " + 當不帶引數開啟Vim時自動載入專案樹 autocmd StdinReadPre * let s:std_in=1 autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif " + 當所有檔案關閉時關閉專案樹窗格 autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif " + 不顯示這些檔案 let NERDTreeIgnore=['\.pyc$', '\~$', 'node_modules'] "ignore files in NERDTree " + 不顯示專案樹上額外的資訊,例如幫助、提示什麼的 let NERDTreeMinimalUI=1 " =>vim-fzf nnoremap <silent> <C-p> :Files<cr> " => NERD Commenter " Add spaces after comment delimiters by default let g:NERDSpaceDelims = 1 " Use compact syntax for prettified multi-line comments let g:NERDCompactSexyComs = 1 " Align line-wise comment delimiters flush left instead of following code indentation let g:NERDDefaultAlign = 'left' " Add your own custom formats or override the defaults let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } } " Allow commenting and inverting empty lines (useful when commenting a region) let g:NERDCommentEmptyLines = 1 " Enable trimming of trailing whitespace when uncommenting let g:NERDTrimTrailingWhitespace = 1 " => SimpleFold set foldmethod=indent au BufWinLeave * silent mkview " 儲存檔案的摺疊狀態 au BufRead * silent loadview " 恢復檔案的摺疊狀態 nnoremap <space> za " 用空格來切換摺疊狀態 " => ale let g:ale_sign_column_always = 1 let g:ale_sign_error = '>>' let g:ale_sign_warning = '--' let g:ale_lint_on_text_changed = 'never' " let g:ale_lint_on_enter = 0 " ================= " end of plug " ================= " vim 命令列模式自動補全 set wildmenu " tab line set showtabline=1 " show matching bracets when text indicator is over them set showmatch " [color scheme] set background=light set t_Co=256 let g:solarized_termcolors = 256 let g:solarized_visibility = "high" let g:solarized_contrast = "high" colorscheme solarized " syntax highlight on syntax on set encoding=utf-8 set guifont=DejaVu\ Sans\ Mono\ 10 "FileType support set filetype=on filetype plugin indent on " Highlight the screen line of the cursor with CursorLine set cursorline " Showing line numbers and length set number " show line numbers set tw=79 " width of document (used by gd) set colorcolumn=80 " Useful settings set history=700 set undolevels=700 " Real programmers don't use TABs but spaces set tabstop=4 set softtabstop=4 set shiftwidth=4 set shiftround set smarttab " set expandtab " Make search case insensitive set hlsearch set incsearch " 實時搜尋功能開啟 set ignorecase " 搜尋時忽略大小寫 set smartcase " Disable stupid backup and swap files - they trigger too many events " for file system watchers set nobackup set nowritebackup set noswapfile

安裝 vim-plug

curl -fLo ~/.vim/autoload/plug.vim --create-dirs  https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

安裝youcompleteme

sudo pacman -S cmake
git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/plugged/YouCompleteMe
cd ~/.vim/bundle/YouCompleteMe
./install.py --clang-completer

安裝其他外掛


  • 找到你要的外掛
  • 去配置檔案配置好

Plugin ‘somebody/someplugin’

  • 開啟vim

  • 輸入安裝命令
    :PlugInstall
  • 如果報錯了

    The ycmd server SHUT DOWN (restart with ‘:YcmRestartServer’). YCM…CM before using it. Follow the instructions in the documentation.

    cd ~/.vim/plugged/YouCompleteMe
    # 或者
    cd ~/.vim/bundle/YouCompleteMe
    ./install.py --clang-completer