vim安裝與配置

vim 8.0python

安裝

git clone https://github.com/vim/vim.gitgit

sudo apt-get install libncurses5-dev  # vim依賴一個ncurses的古老庫github

./configure --prefix=~/usr/vim-8.0/ --enable-pythoninterp --enable-multibyte --enable-rubyinterpvim

makeruby

make installbash

查看當前vim環境

:scriptname 查看加載的配置文件app

:verbose map [key_name] 查看key_name按鍵映射ide

:verbose set 查看全部set,如set paste函數

:verbose history 查看歷史命令ui

:function [fun-name] 列出函數

F5運行當前腳本

map <F5> :call CompileRunGcc()<CR>
func! CompileRunGcc()
    exec "w"
    if &filetype == 'c'
        :!if gcc % -o %<; then time ./%<; fi
    elseif &filetype == 'cpp'
        :!if g++ % -o %<; then time ./%<; fi
    elseif &filetype == 'sh'
        :!time bash %
    elseif &filetype == 'python'
        :!time python %
    endif
endfunc

Vundle插件管理器

1 下載vundle

git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle

2 配置.vimrc

set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'

" Keep Plugin commands between vundle#begin/end.
call vundle#end()            " required
filetype plugin indent on    " required

vim基本配置

從vim的default.vim中修改的

set nocompatible
set backspace=indent,eol,start  "Allow backspacing over everything in insert mode.
set history=200        " keep 200 lines of command line history
set ruler        " show the cursor position all the time
set showcmd        " display incomplete commands
set wildmenu        " display completion matches in a status line
set hlsearch            " hightlight searched phase
set ttimeout        " time out for key codes
set ttimeoutlen=100    " wait up to 100ms after Esc for special key
set display=truncate    " Show @@@ in the last line if it is truncated.
set scrolloff=5         "Show a few lines of context around the cursor
set incsearch           " Do incremental searching when it's possible to timeout.
set mouse=a
set number
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4

syntax on

" Don't use Ex mode, use Q for formatting.  Revert with ":unmap Q".
map Q gq


" Only do this part when compiled with support for autocommands.
if has("autocmd")

  " Enable file type detection.
  " Use the default filetype settings, so that mail gets 'tw' set to 72,
  " 'cindent' is on in C files, etc.
  " Also load indent files, to automatically do language-dependent indenting.
  " Revert with ":filetype off".
  filetype plugin indent on

  " Put these in an autocmd group, so that you can revert them with:
  " ":augroup vimStartup | au! | augroup END"
  augroup vimStartup
    au!

    " When editing a file, always jump to the last known cursor position.
    " Don't do it when the position is invalid or when inside an event handler
    " (happens when dropping a file on gvim).
    autocmd BufReadPost *
      \ if line("'\"") >= 1 && line("'\"") <= line("$") |
      \   exe "normal! g`\"" |
      \ endif

  augroup END

endif " has("autocmd")

" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
" Revert with: ":delcommand DiffOrig".
if !exists(":DiffOrig")
  command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
          \ | wincmd p | diffthis
endif

if has('langmap') && exists('+langremap')
  " Prevent that the langmap option applies to characters that result from a
  " mapping.  If set (default), this may break plugins (but it's backward
  " compatible).
  set nolangremap
endif

 

YouCompleteMe

  1. vundlle管理YCM,在.vimrc相應位置加上Plugin 'Valloric/YouCompleteMe'
  2. 打開vim,運行:PluginInstall,安裝插件
  3. 進入~/.vim/bundle/YouCompleteMe/,運行./install.py(--clang-completer支持C系列語言補全,須要安裝llvm+clang)

可能須要注意:

  1. vim python support
  2. git用來下載YCM的問題
  3. cmake默認編譯器的問題(export CC和CXX到高版本的編譯器)
相關文章
相關標籤/搜索