vim 插件管理 Vundle

2023-10-22 15:44:51 浏览数 (2)

vim 插件管理 Vundle [https://github.com/VundleVim/Vundle.vim]:

1.下载 Vundle 仓库

代码语言:javascript复制
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

2.vim ~/.vimrc 在最上面,添加以下配置

代码语言:javascript复制
" =================== Vundle 插件安装 start ================
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/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}

" plugin on GitHub repo "https://github.com/scrooloose/nerdtree
" 目录树
Plugin 'scrooloose/nerdtree'

" VIM 中文文档
Plugin 'asins/vimcdoc'

" 文件跳转
Plugin 'kien/ctrlp.vim'

" ag 全局搜索
Plugin 'rking/ag.vim'

" 代码分析
Plugin 'majutsushi/tagbar'

" 主题
Plugin 'chriskempson/base16-vim'
Plugin 'sickill/vim-monokai'

" 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
" =================== Vundle 插件安装 end ================


" =================== 插件配置 start ================
" scrooloose/nerdtree 目录树设置 
map <F3> :NERDTreeMirror<CR>
map <F3> :NERDTreeToggle<CR>
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'

" asins/vimcdoc VIM 中文文档设置
let helptags=$VIM."/vimfiles/doc"
set helplang=cn

" kien/ctrlp.vim 文件跳转设置
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_custom_ignore = 'v[/].(git|hg|svn|pyc)$' " 设置过滤不进行查找的后缀名

" rking/ag.vim ag 全局搜索设置
" let g:ag_highlight=1
let g:ag_prg="ag --vimgrep --smart-case"
let g:ag_working_path_mode="r" " 总是从项目根目录开始搜索

" majutsushi/tagbar 代码分析设置
nmap <F8> :TagbarToggle<CR> 
" =================== 插件配置 end ================


" =================== 我的配置 start ================
" 设置 leader 键,以下为空格键,也可以设置为其它 默认为"/"
let mapleader=" "  

syntax enable       " monokai
colorscheme monokai " monokai
" colorscheme base16-default-dark " chriskempson/base16-vim 主题

" 设置快捷键,关闭一个窗口
map <leader>wq :wq<CR>
map <leader>g :Ag 

syntax on    " 显示高亮
" set cursorline " 突出显示当前行
set smartindent " 开启新行时使用智能自动缩进
set nocompatible " 关闭 vi 兼容模式
set encoding=utf-8
set fileencoding=utf-8
set fileformat=unix "从Win上复制文件时,避免换行符错误
set ts=4
set expandtab
set shiftwidth=4 " 设定 << 和 >> 命令移动时的宽度为 4
set softtabstop=4 " 使得按退格键时可以一次删掉 4 个空格
set autoread " 文件修改之后自动载入
set number   " 显示行号
set ignorecase "搜索忽略大小写
set noerrorbells " 去掉输入错误的提示声音
set novisualbell " 去掉输入错误的提示声音
set paste " 粘贴时保持格式
" =================== 我的配置 end ================

3.命令行执行,安装插件

代码语言:javascript复制
vim
:PluginInstall

ps

1) NerdTree 使用手册

代码语言:javascript复制
?: 快速帮助文档
o: 打开一个目录或者打开文件,创建的是buffer,也可以用来打开书签
go: 打开一个文件,但是光标仍然留在NERDTree,创建的是buffer
t: 打开一个文件,创建的是Tab,对书签同样生效
T: 打开一个文件,但是光标仍然留在NERDTree,创建的是Tab,对书签同样生效
i: 水平分割创建文件的窗口,创建的是buffer
gi: 水平分割创建文件的窗口,但是光标仍然留在NERDTree
s: 垂直分割创建文件的窗口,创建的是buffer
gs: 和gi,go类似
x: 收起当前打开的目录
X: 收起所有打开的目录
e: 以文件管理的方式打开选中的目录
D: 删除书签
P: 大写,跳转到当前根路径
p: 小写,跳转到光标所在的上一级路径
K: 跳转到第一个子路径
J: 跳转到最后一个子路径
<C-j>和<C-k>: 在同级目录和文件间移动,忽略子目录和子文件
C: 将根路径设置为光标所在的目录
u: 设置上级目录为根路径
U: 设置上级目录为跟路径,但是维持原来目录打开的状态
r: 刷新光标所在的目录
R: 刷新当前根路径
I: 显示或者不显示隐藏文件
f: 打开和关闭文件过滤器
q: 关闭NERDTree
A: 全屏显示NERDTree,或者关闭全屏

2) Ag 依赖 ag mac: https://github.com/ggreer/the_silver_searcher windows: https://github.com/k-takata/the_silver_searcher-win32

0 人点赞