700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > vim配置以及Vundle安装插件

vim配置以及Vundle安装插件

时间:2024-03-28 14:17:19

相关推荐

vim配置以及Vundle安装插件

文章目录

配置vim设置vim C/C++开发环境安装Vundle进行插件管理输入以下命令配置插件安装插件括号和引号匹配自动补全Formatter

配置vim

设置vim C/C++开发环境

~/.vimrc中输入以下内容

set enc=utf-8set fenc=utf-8set termencoding=utf-8" disable vi compatibility (emulation of old bugs)set nocompatible" use indentation of previous lineset autoindent" use intelligent indentation for Cset smartindent" configure tabwidth and insert spaces instead of tabsset tabstop=4 " tab width is 4 spacesset shiftwidth=4" indent also with 4 spacesset expandtab " expand tabs to spaces" wrap lines at 120 chars. 80 is somewaht antiquated with nowadays displays.set textwidth=120" turn syntax highlighting onset t_Co=256syntax on" colorscheme wombat256" turn line numbers onset number" highlight matching bracesset showmatch" intelligent commentsset comments=sl:/*,mb:\ *,elx:\ */" Install OmniCppComplete like described on /wiki/C++_code_completion" This offers intelligent C++ completion when typing ‘.’ ‘->’ or <C-o>" Load standard tag filesset tags+=~/.vim/tags/cppset tags+=~/.vim/tags/glset tags+=~/.vim/tags/sdlset tags+=~/.vim/tags/qt4" Install DoxygenToolkit from /scripts/script.php?script_id=987let g:DoxygenToolkit_authorName="John Doe <john@>"" Enhanced keyboard mappings"" in normal mode F2 will save the filenmap <F2> :w<CR>" in insert mode F2 will exit insert, save, enters insert againimap <F2> <ESC>:w<CR>i" switch between header/source with F4map <F4> :e %:p:s,.h$,.X123X,:s,.cpp$,.h,:s,.X123X$,.cpp,<CR>" recreate tags file with F5map <F5> :!ctags -R –c++-kinds=+p –fields=+iaS –extra=+q .<CR>" create doxygen commentmap <F6> :Dox<CR>" build using makeprg with <F7>map <F7> :make<CR>" build using makeprg with <S-F7>map <S-F7> :make clean all<CR>" goto definition with F12map <F12> <C-]>" in diff mode we use the spell check keys for mergingif &diff” diff settingsmap <M-Down> ]cmap <M-Up> [cmap <M-Left> domap <M-Right> dpmap <F9> :new<CR>:read !svn diff<CR>:set syntax=diff buftype=nofile<CR>ggelse" spell settings:setlocal spell spelllang=en" set the spellfile - folders must existset spellfile=~/.vim/spellfile.addmap <M-Down> ]smap <M-Up> [sendif

安装Vundle进行插件管理

输入以下命令

git clone /VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

配置插件

把以下命令输入~/.vimrc的顶部

set nocompatible " be iMproved, requiredfiletype off " required" set the runtime path to include Vundle and initializeset rtp+=~/.vim/bundle/Vundle.vimcall vundle#begin()" alternatively, pass a path where Vundle should install plugins"call vundle#begin('~/some/path/here')" let Vundle manage Vundle, requiredPlugin 'VundleVim/Vundle.vim'" The following are examples of different formats supported." Keep Plugin commands between vundle#begin/end." plugin on GitHub repoPlugin 'tpope/vim-fugitive'" plugin from http://vim-/vim/scripts.html" Plugin 'L9'" Git plugin not hosted on GitHubPlugin 'git:///command-t.git'" git repos on your local machine (i.e. when working on your own plugin)Plugin 'file:///home/gmarik/path/to/plugin'" The sparkup vim script is in a subdirectory of this repo called vim." Pass the path to set the runtimepath properly.Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}" Install L9 and avoid a Naming conflict if you've already installed a" different version somewhere else." Plugin 'ascenator/L9', {'name': 'newL9'}. Plugin 'Raimondi/delimitMate' . Plugin 'Chiel92/vim-autoformat' . Plugin 'ycm-core/YouCompleteMe' Plugin 'flazz/vim-colorschemes' " All of your Plugins must be added before the following linecall vundle#end() " requiredfiletype plugin indent on " required

安装插件

打开vim然后输入:PluginInstall命令来安装插件。

vim下方出现Done表示安装成功。

括号和引号匹配

可以安装delimitMate插件处理各种括号和引号匹配的问题。

可以使用Vundle的形式安装。

~/.vimrc添加Plugin 'Raimondi/delimitMate',然后打开vim输入:PluginInstall进行插件安装。

自动补全

对于代码自动补全功能,可以安装YouCompleteMe。

首先输入以下命令

cd ~/.vim/bundlegit clone /ycm-core/YouCompleteMe.git

下载完成后进入YCM目录下

cd ~/.vim/bundle/YouCompleteMe

然后输入以下命令

git submodule --init --recursive

这个过程比较慢,如果初始化不成功,需要手动初始化。

以上过程结束后,需要执行下面的文件

./install.py

安装完毕之后,在~/.vimrc中添加

Plugin 'ycm-core/YouCompleteMe'

打开vim输入:PluginInstall安装插件。

Formatter

vim中提供格式化功能。

~/.vimrc中输入

Plugin 'Chiel92/vim-autoformat'

然后打开vim,输入:PluinInstall进行插件的安装。

vim-autoformat只是一个格式化框架,还需要安装其他工具才可以格式化代码。其他工具点击这里,打开网站进行安装即可。

如安装astyle,点击。

输入

$ sudo apt-get install astyle

网站上有一些对应的配置。配置。

~/.vimrc中输入

let g:formatdef_harttle = '"astyle --style=kr --pad-oper -xg -c -N"'let g:formatters_cpp = ['harttle']noremap <F3> :Autoformat<CR>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。