vim 插件配置整理

8 篇文章 0 订阅
6 篇文章 0 订阅

1、插件管理器

Vundle是一个流行的vim插件管理器,它的网址是https://github.com/VundleVim/Vundle.vim

以下是安装步骤:

  1. git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
    如果目录.vim/bundle不存在请先创建
  2. 打开~/.vimrc,在文件头加入以下内容
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vundle
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'

" 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/'}
" Avoid a name conflict with L9
"Plugin 'user/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


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  1. 从其中的注释可以知道,Vundle支持多种形式的插件源,并给出了示例。这些插件源包括:github上的插件、http://vim-scripts.org/vim/scripts.html上的插件、非github上的git插件、本地硬盘上的插件等。

  2. 打开vim,运行 :PluginInstall 命令来自动安装插件,过程中有可能需要输入github用户名和密码。等待Vundle安装完成即可。

Vundle正在自动安装在.vimrc中指定的插件:

 

2、Doxygen注释自动生成

为自己的代码写好注释是一个良好的习惯,而编写Doxygen风格的注释更是可以通过doxygen工具为代码自己生成文档,非常好用。DoxygenToolkit(https://github.com/vim-scripts/DoxygenToolkit.vim)就是这样的一个插件。安装和使用:

  1. 在~/.vimrc中的Vundle插件列表区域中添加DoxygenToolkit的源位置
    Plugin 'vim-scripts/DoxygenToolkit.vim'
    保存后退出,再打开vim,运行:PluginInstall命令安装
  2. 在~.vimrc中,Vundle区域后的某处,设置DoxygenToolkit插件在@author区域自动填充的作者名称,比如
let g:DoxygenToolkit_authorName="author" 
  1. 使用时,将光标定位到文件首行,输入:DoxAuthor将插入文件头注释骨架(第一次会让你输入文件版本号);
  2. 并把光标停留在@brief 后面,等待输入文件描述。在光标定位到数据结构声明或函数声明的第一行,运行:Dox,将生成数据结构或函数的注释骨架;

3、nerdtree树形目录

在.vimrc中加入

Bundle 'The-NERD-tree'
Bundle 'The-NERD-Commenter'

然后执行 
vim
然后执行安装命令
:BundleInstall

使用命令

:NERDTree  进入树形界面
:NERDTreeToggle  关闭树形

设置默认开启  .vimrc中添加  autocmd VimEnter * NERDTree

显示与隐藏
map <F3> :NERDTreeMirror<CR>
map <F3> :NERDTreeToggle<CR>


常用命令
和编辑文件一样,通过h j k l移动光标定位
打开关闭文件或者目录,如果是文件的话,光标出现在打开的文件中
go 效果同上,不过光标保持在文件目录里,类似预览文件内容的功能
i和s可以水平分割或纵向分割窗口打开文件,前面加g类似go的功能
t 在标签页中打开
T 在后台标签页中打开
ctrl+w+w 光标在左右窗口切换
ctrl+w+r 切换当前窗口左右布局
ctrl+p 模糊搜索文件
gT 切换到前一个tab
g t 切换到后一个tab
p 到上层目录
P 到根目录
K 到同目录第一个节点
J 到同目录最后一个节点
m 显示文件系统菜单(添加、删除、移动操作)
r: 刷新光标所在的目录
R: 刷新当前根路径
? 帮助
q 关闭

参考:

https://www.jianshu.com/p/58de4d7109d6

https://www.cnblogs.com/zzqcn/p/4660615.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值