SkillAgentSearch skills...

VimScripts

myself vim scripts

Install / Use

/learn @tenfyzhong/VimScripts
About this skill

Quality Score

0/100

Supported Platforms

Universal

Tags

README

VimScripts

安装说明

类unix

将克隆下来的VimScripts重命名为.vim,然后运行bin/unix/install.sh:

mv ~/.vim ~/.vim.bak # 备份之前自己的vim配置,若不存在则不用此操作
mv VimScripts ~/.vim
sh ~/.vim/install.sh

windows

安装msysgit 将克隆下来的VimScripts重命令为vimfiles,然后运行bin\windows\install.bat 如果windows系统安装了python,vim会支持python。但是默认会从C:\Python27目录去 查找python(以python2.7为例),如果找不到vim会crash。需要设置系统变量

PYTHONPATH=C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk

common

在.vimrc中将g:use_chinese_doc设为1则使用中文文档。 若不成功,请运行:PlugInstall

配置

通过配置g:type_plugin_list来加载vimrcs下子目录的插件,vimrcs下的插件默认全部 加载。g:type_plugin_list是一个列表。如果要加载所有的插件,只要包含'**'项即 可。配置例子:

let g:type_plugin_list = ["c", "go", "web"]

以上的例子会加载vimrcs目录下的c,go,web目录下的插件。

说明

对于要使用cscope的项目,在项目根路径生成cscope的数据库,用以下命令:

~/.vim/bin/unix/cscope.sh

cscope会从当前目录一直往上去查找cscope目录,找到则链接

加入插件,在 ~/.vim/vimrcs/ 下加入一个.vimrc或.vim后缀的脚本, 在脚本开头调用Plug命令 加载插件,脚本下面可以加入其他的配置。例如:

Plug 'a.vim'

对于不使用的插件,可以有以下操作:

  • 将其移到unused_vimrcs目录下(建议)
  • 将其脚本删除
  • 将其.vimrc的后缀重命名为其他
  • 在脚本的开头加上 finish

本地目录下增加.vimrc(windows下为_vimrc),可以在加载完home目录下的.vimrc文件后, 加载插件之前,去加载这个文件。可以在这个文件里做一些特殊的配置。比如可以调用 g:type_plugin_list来加载特定的插件。

对于大于100K的文件,如果foldmethod为syntax,会将它设成indent,以加快打开速度

建议

在crontab中加入清除备份文件和undo文件的脚本

0 3 * * * find /home/tenfyzhong/.vim/.backupfile -mtime +10 -name "*~" -delete
0 3 * * * find /home/tenfyzhong/.vim/.undofile -mtime +10 -name "%*" -delete

注意

  • vim版本使用最新的版本,否则有些特性用不了
  • YouCompleteMe的安装说明请参考其文档。

自编译vim建议

加入以下的属性 --with-features=huge --enable-rubyinterp --enable-pythoninterp --enable-python3interp --enable-luainterp --enable-perlinterp --enable-multibyte --enable-cscope --enable-gui=gtk2

  • --with-features=huge:支持最大特性
  • --enable-rubyinterp:启用Vim对ruby编写的插件的支持
  • --enable-pythoninterp:启用Vim对python编写的插件的支持
  • --enable-python3interp:启用Vim对python3编写的插件的支持
  • --enable-luainterp:启用Vim对lua编写的插件的支持
  • --enable-perlinterp:启用Vim对perl编写的插件的支持
  • --enable-multibyte:多字节支持 可以在Vim中输入中文
  • --enable-cscope:Vim对cscope支持
  • --enable-gui=gtk2:gtk2支持,也可以使用gnome,表示生成gvim

依赖程序

  • git:用于版本管理
  • ctags:tags,如tagbag等要用到
  • clang:youcompleteme需要用到
  • cscope:生成cscope.out
  • doxygen:用于生成代码文档
  • sbcl:common lisp的编译器,slimv用到
  • xterm:运行lisp解析器服务器

命令

| command | args | describe | |:------------|:-------|:------------| | Bigger | | 加大gui字体 | | Smaller | | 缩小gui字体 | | W | | sudo保存 |

键映射

以下model, n对应normal, i对应insert, v对应visual, c对应console, x对应选择模式 o对应motion模式

| map | model | script | describe | |--------------------|:------|:-------------------|:----------------------------------------| | <leader>w | n | global | 保存所有文件 | | j | n | global | 不指定行数时为gj,指定行数时为j | | k | n | global | 不指定行数时为gk,指定行数时为k | | gj | n | global | j | | gk | n | global | k | | ; | nx | global | : | | , | n | global | ; | | <m-,> | n | global | , | | [1 | n | global | diff时取窗口1的内容 | | [2 | n | global | diff时取窗口2的内容 | | [3 | n | global | diff时取窗口3的内容 | | [4 | n | global | diff时取窗口4的内容 | | ]1 | n | global | diff时将内容放到窗口1 | | ]2 | n | global | diff时将内容放到窗口2 | | ]3 | n | global | diff时将内容放到窗口3 | | ]4 | n | global | diff时将内容放到窗口4 | | <c-k> | c | global | 命令行上滚 | | <c-j> | c | global | 命令行下滚 | | <Space><Space> | n | global | zA | | <leader>n | n | global | 切换行号模式 | | < | v | global | <gv | | > | v | global | >gv | | ag | o | global | 整个文件的motion动作 | | <leader>tn | n | global | :tabnew | | <leader>tc | n | global | :tabclose | | <leader>cf | n | global | 复制文件名(不包括路径)到匿名缓存区 | | <leader>cp | n | global | 复制文件名和路径到匿名缓存区 | | <leader>p | n | global | pastetoggle | | <c-p> | n | global | redraw! | | <leader>xx | n | global | 在16进制的xxd中切换 | | <space>o | n | global | 在上面添加[count]个空行 | | <space>O | n | global | 在下面添加[count]个空行 | | <leader>p | n | global | 切换patse模式 | | <leader>y | n | global | 复制内容到系统粘贴板 | | <leader>et | n | global | 转换和打印当前光标的时间戳 | | <leader>scl | n | global | 转成小写开头的驼峰 | | <leader>scu | n | global | 转成大写开头的驼峰 | | <leader>sul | n | global | 转成小写的下线划 | | <leader>suu | n | global | 转成大写的下线划 | | <leader>aa | n | a.vim | 在源文件和头文件中切换 | | <leader>as | n | a.vim | 水平打开源文件或者头文件对应的另一部分 | | <leader>av | n | a.vim | 竖直打开源文件或者头文件对应的另一部分 | | <C-\>s | n | cscope | 查找这个C符号 | | <C-\>g | n | cscope | 查找这个定义 | | <C-\>c | n | cscope | 查找调用这个函数的函数 | | <C-\>t | n | cscope | 查找这个字符串 | | <C-\>e | n | cscope | 查找这个egrep匹配模式 | | <C-\>f | n | cscope | 查找这个文件 | | <C-\>i | n | cscope | 查找#include这个文件的文件 | | <C-\>d | n | cscope | 查找被这个函数调用的函数 | | <C-_>ss | n | cscope | 查找这个C符号,水平切分窗口 | | <C-_>sg | n | cscope | 查找这个定,水平切分窗口义 | | <C-_>sc | n | cscope | 查找调用这个函数的函,水平切分窗口数 | | <C-_>st | n | cscope | 查找这个字符,水平切分窗口串 | | <C-_>se | n | cscope | 查找这个egrep匹配模,水平切分窗口式 | | <C-_>sf | n | cscope | 查找这个文,水平切分窗口件 | | <C-_>si | n | cscope | 查找#include这个文件的文,水平切分窗口件 | | <C-_>sd | n | cscope | 查找被这个函数调用的函,水平切分窗口数 | | <C-_>vs | n | cscope | 查找这个C符号,竖直切分窗口 | | <M-_>vg | n | cscope | 查找这个定,竖直切分窗口义 | | <M-_>vc | n | cscope | 查找调用这个函数的函,竖直切分窗口数 | | <M-_>vt | n | cscope | 查找这个字符,竖直切分窗口串 | | <M-_>ve | n | cscope | 查找这个egrep匹配模,竖直切分窗口式 | | <M-_>vf | n | cscope | 查找这个文,竖直切分窗口件 | | <M-_>vi | n | cscope | 查找#include这个文件的文,竖直切分窗口件 | | <M-_>vd | n | cscope | 查找被这个函数调用的函,竖直切分窗口数 | | <leader>tg | n | ctags | 在当前目录生成tags | | <c-l> | n | ctrlspace | tablist中的下一个文件 | | <c-h> | n | ctrlspace | tablist中的上一个文件 | | <leader>nt | n | nerdtree | 触发nerdtree | | <leader>nc | n | nerdtree | NERDTreeCWD | | <leader>np | n | nerdtree | NERDTree parent | | <leader>nf | n | nerdtree | NERDTree % | | <leader>tb | n | tagbar or taglist | 触发tagbar or taglist | | <leader>ta | n | tagbar or taglist | 触发tagbar和nerdtree | | <leader>tf | n | tagbar | 跳到tagbar,没打开则打开 | | <leader>qk | n | quickfix | 上一条错误警告处 | | <leader>qj | n | quickfix | 下一条错误警告处 | | <leader>qc | n | quickfix | 关闭quickfix或者loclist | | <leader>qo | n | quickfix | 打开quickfix或者loclist | | <leader>qq | n | quickfix | 打开quickfix | | <leader>ql | n | quickfix | 打开loclist | | <leader>dx | n | Doxygen | 生成函数和类注释 | | <leader>da | n | Doxygen | 生成文件注释 | | <leader>dl | n | Dox

Related Skills

View on GitHub
GitHub Stars13
CategoryDevelopment
Updated2y ago
Forks3

Languages

Vim Script

Security Score

70/100

Audited on Oct 21, 2023

No findings