如何在git for Windows上配置vim及安装插件

安装插件

安装好 git 后使用Vundle进行 Vim 的插件管理
C:\Users\xxx\.vim 文件夹下,Git bash here
git clone https://github.com/VundleVim/Vundle.vim.git

vim 配置

此时vim的配置文件在 git 安装目录下的 etc 文件夹下,如
D:\Program Files\Git\etc
编辑其中的文件vimrc,具体的配置文件见仁见智,网络上有很多。

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平台下 Vim

主要介绍使用的插件和功能,具体可查阅网上的信息。

安装ctags及cscope

sudo apt-get 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

  1. http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/#navigation ↩︎

猜你喜欢

转载自blog.csdn.net/FJDJFKDJFKDJFKD/article/details/85139176