首页 > 代码库 > vim配置

vim配置

vim 8.0

查看当前vim环境

:scriptname 查看加载的配置文件

:verbose map [key_name] 查看key_name按键映射

:verbose set 查看所有set,如set paste

:verbose history 查看历史命令

: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 %    endifendfunc

Vundle插件管理器

1 下载vundle

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

2 配置.vimrc

set nocompatible              " be iMproved, requiredfiletype off                  " required" set the runtime path to include Vundle and initializeset rtp+=~/.vim/bundle/Vundle.vimcall vundle#begin()Plugin VundleVim/Vundle.vim" Keep Plugin commands between vundle#begin/end.call vundle#end()            " requiredfiletype plugin indent on    " required

vim基本配置

从vim的default.vim中修改的

技术分享
set nocompatibleset backspace=indent,eol,start  "Allow backspacing over everything in insert mode.set history=200        " keep 200 lines of command line historyset ruler        " show the cursor position all the timeset showcmd        " display incomplete commandsset wildmenu        " display completion matches in a status lineset hlsearch            " hightlight searched phaseset ttimeout        " time out for key codesset ttimeoutlen=100    " wait up to 100ms after Esc for special keyset display=truncate    " Show @@@ in the last line if it is truncated.set scrolloff=5         "Show a few lines of context around the cursorset incsearch           " Do incremental searching when it‘s possible to timeout.set mouse=aset numbersyntax 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 ENDendif " 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 | diffthisendifif 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 nolangremapendif
View Code

 

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到高版本的编译器)

 

vim配置