vim编辑代码自动补全设置

1.安装vundle插件

执行:git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim 从git下面下载vundle.vim文件

将如下文本设置到/etc/vimrc中

set nocompatible              " be iMproved, required
"filetype off                  " required   这个需要设置为on,用来识别自动文本类型

" 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'

" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/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'}

" 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

参考:

https://github.com/VundleVim/Vundle.vim

http://www.jianshu.com/p/0e85e7c9e543#


2.设置/etc/vimrc内容

添加如下设置:

syn on
filetype on
set number
set ruler
set hls
set history=500
"set cursorline
"set laststatus=2
"set cmdheight=1
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
set smarttab
set autoindent
set smartindent
set cindent
"set showcmd
set showmatch


3.自动对齐设置命令

进入vim,先选择行数,再按下“=”号两次,即可自动对齐

如:按下300,再按下“=”两次,可以将文本的光标以下300行自动对齐。




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
里面的vim插件已经包含了taglist,omnicppcomplete等插件,无需再下载,详细的配置参考.vimrc,注意快捷键使用即可。有什么不喜欢和bug的地方,自行调整.vimrc。ctags命令工具还是要下载安装的。 1. 安装ctags和cscope yum install即可 在.vimrc文件中增加map :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q . 就可以在vim中使用快捷键F12来随时生成当前目录下的tags,这样后续配好omni自动补全以后,自己工程下定义的类中的public成员,也可以通过. :: ->来自动补全了。全局定义的查找。局部的符号不会生成tags,这个要使用superTab。 Ctrl ] 跳转到光标所在位置的符号的定义,前提是tags中有。 Ctrl t 回到上次跳转前的位置。 2. 下载其他vim插件 echofunc.vim 在底部状态栏显示函数原型 Alt - 和 Alt + 可以在多个函数原型间切换 winmanager 侧边栏显示文件浏览 直接把.vim文件拷贝到~/.vim/plugin/下即可 自动打开winmanager,参考http://blog.csdn.net/xuanwu_yan/article/details/43736299 : 在.vimrc中添加: let g:autoOpenWinManager=1 然后需要手动修改winmanager.vim文件,在末尾加入: " set auto open WinManager if g:autoOpenWinManager autocmd VimEnter * nested call s:StartWindowsManager() endif 调整winmanager窗口的大小,参考http://blog.csdn.net/yangzhongxuan/article/details/7944927 : let g:bufExplorerMaxHeight=30 let g:bufExplorerMoreThanOne=0 miniBufferExplorer,直接下载minibufexpl.vim 折叠设置 " --fold setting --- set foldmethod=syntax "用语法高亮来定义折叠 set foldlevel=100 "启动vim时不要自动折叠代码 set foldcolumn=5 "设置折叠栏宽度 常用命令: za 打开/关闭在光标下的折叠 zA 循环地打开/关闭光标下的折叠 zc 关闭close在光标下的折叠 zo 打开在光标下的折叠 安装SuperTab,参考http://blog.csdn.net/bokee/article/details/6633193 ,配了之后没反应 使Tab键具有更快捷的上下文提示功能,从http://www.vim.org/scripts/script.php?script_id=1643 下载安装,它是个vba文件,即Vimball格式的安装包,安装方法: 1)用vim打开supertab.vba文件 2)在vim命令行下运行命令UseVimball ~/.vim。就会将安装包安装到~/.vim目录下。 在~/.vimrc文件中添加: let g:SuperTabDefaultCompletionType="" 使用Ctrl - P键弹出SuperTab的自动补全 Ctrl - w - ] 弹出定义的位置 Ctrl - ] 跳到符号定义的位置,Ctrl - t返回上次跳走的位置 Ctrl-x Ctrll-o 弹出omni自动补全 F12 生成当前目录下的tags

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值