Using Vim as c/c++ editor

1. install VIM plugin management Vundlelinux

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

Put this at the top of ~/.vimrc filegit

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()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

Plugin 'Valloric/YouCompleteMe'




" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList       - lists configured plugins
" :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line

2.Install pathogengithub

mkdir -p ~/.vim/autoload ~/.vim/bundle && \
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim

将下面代码添加到.vimrcvim

execute pathogen#infect()
syntax on
filetype plugin indent on

3. install code auto complete plugin YouCompleteMe 测试发现经过Vundle安装YouCompleteMe不成功,只能经过下面手工方法安装此插件windows

cd ~/.vim/bundle
git clone https://github.com/Valloric/YouCompleteMe.git
cd YouCompleteMe
git submodule update --init --recursive
./install.py --clang-completer --system-libclang
cd ~/.vim/
wget https://github.com/Valloric/ycmd/blob/master/cpp/ycm/.ycm_extra_conf.py

将下面配置放到.vimrc 后面bash

let g:ycm_global_ycm_extra_conf = "~/.vim/.ycm_extra_conf.py"
let g:ycm_key_list_select_completion=[]
let g:ycm_key_list_previous_completion=[]

编辑一个.c文件查看YouCompleteMe的效果。app

四、总结curl

要打造一款合适的vim工具仍是挺啰嗦的,如无必要,最好仍是用IDE,不要浪费时间在上面!这里个有连接推荐的IDE,通常windows平台用visual studio,Linux或Mac OS用IDEA。ide

参考:工具

http://www.alexeyshmalko.com/2014/youcompleteme-ultimate-autocomplete-plugin-for-vim/

http://www.alexeyshmalko.com/2014/using-vim-as-c-cpp-ide/

http://www.tecmint.com/vi-editor-usage/

相关文章
相关标签/搜索