安装 vim 插件
安装好 git for windows 后可选择使用 Vundle
进行 vim
插件的管理。在C:\Users\xxx\.vim\bundle
文件夹下,如果没有这个目录,可以新建该文件夹,然后 Git bash here。
git clone https://github.com/VundleVim/Vundle.vim.git
vim 配置
vim 的配置文件在 git 安装目录下的 etc 文件夹下,如 D:\Program Files\Git\etc
。
编辑其中的文件 vimrc
即可,具体的配置见仁见智,网络上有很多,这里不展开。
错误解决
VIM python 不能加载的问题。无法加载库 msys-pythonxxx.dll
。这个需要主动设置python dll路径。
# 例如
set pythonthreedll=D:/Program\ Files/Python38/python38.dll
git bash 配置
git 的配置可针对当前的工程或者针对当前的用户。
前者放在工程文件的 .git/config
文件中。
后者配置的时候需要增加 --global
选项,配置文件为 .gitconfig
。
两者都可以直接编辑相关的配置文件或者通过命令行配置。
git bash 配置别名
windows下可在Git安装目录如D:\Program Files\Git\etc\profile.d\aliases.sh
进行 git bash 中命令别名的配置。如:
alias cls='clear'
...
可以在 C:\Users\xxx\.gitconfig
进行 git 自身命令的别名配置。
[alias]
st = status
...
关于ctags和taglist的安装问题
taglist 依赖于ctags。ctags可以从这里下载 ctags5.8。
解压后将其中的ctags.exe
放到git安装目录下的 usr\bin
目录下,如 D:\Program Files\Git\usr\bin
。
ctags 使用
有时候我们希望忽略某些文件或者文件夹,不生成相关数据库。
ctags
提供了 --exclude
选项。ctags -R --exclude=dir1 --exclude=dir2 --exculde=for_exclude.c
同样也可以收集好想生成数据库的文件给ctags。
$ find . -name "*.h" -o -name "*.asm" -o -name "*.cpp" > data.txt`
$ ctags -L data.txt
关于 cscope 的使用问题
window 下我目前没有找到相关的安装方式,大家如果安装成功的请留言分享哈~
关于 cscope 的数据库生成
有时候我们希望忽略某些文件或者文件夹,不生成相关数据库。
cscope 没有 ctags 的 --exclude
选项。我们可以使用find命令把要生成数据库的文件收集起来给cscope。
The standard procedure is to use the ‘find’ utility (if Unix), or your own script, to build a file that contains a list of each file you want indexed, then feed that to cscope with the -i option
$ find . -name "*.h" -o -name "*.asm" -o -name "*.cpp" > data.txt
$ cscope -bq -i data.txt
Linux 平台
主要介绍使用的插件和功能,具体可查阅网上的信息。
安装 ctags 及 cscope
sudo apt install exuberant-ctags cscope
安装Vundle
Vundle可以作为Vim的包管理插件。方便与.vimrc
一同完成 Vim 环境的移植。
Vundle常用的指令如下:
- :PluginList lists configured plugins
- :PluginInstall installs plugins; append `!` to update or just :PluginUpdate
- :PluginClean confirms removal of unused plugins; append `!` to auto-approve removal
- :PluginUpdate
- :PluginSearch foo searches for foo; append `!` to refresh local cache
安装方式如下:
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
可以安装的Vim插件如下,作参考。
Plugin ‘Yggdroot/indentLine’
Plugin ‘ntpeters/vim-better-whitespace’
Plugin ‘vim-airline/vim-airline’
Plugin ‘tpope/vim-fugitive’
Plugin ‘chazy/cscope_maps’
Plugin ‘vim-scripts/taglist.vim’
Plugin ‘scrooloose/nerdtree’
Plugin ‘wesleyche/SrcExpl’
Plugin ‘wesleyche/Trinity’
Plugin ‘majutsushi/tagbar’
Vim进阶
参考自1
%: Go to the corresponding ( { [
*: go to next occurrence of the world under the cursor
#: go to previous occurrence of the world under the cursor
http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/#navigation ↩︎