关于vim插件:vim-python代码补全
coc.vim python代码补全补全成果如图: 办法装置coc.vim装置coc-python配置python门路,我用的是conda管制我的python版本等问题,所以须要在coc-settings.json文件中增加如下代码: $ vi ~/.vim/coc-settings.json{ "python.condaPath":"path/miniconda3/python.app"}
coc.vim python代码补全补全成果如图: 办法装置coc.vim装置coc-python配置python门路,我用的是conda管制我的python版本等问题,所以须要在coc-settings.json文件中增加如下代码: $ vi ~/.vim/coc-settings.json{ "python.condaPath":"path/miniconda3/python.app"}
装置YouCompleteMe问题依照YouCompleteMe的步骤装置之后发现报错信息如下: The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). Unexpected exit code -6起因自己设置了python的门路为conda装置的python门路,所以导致以上问题,应应用本人装置的python编译 解决办法cd ~/.vim/bundle/YouCompleteMe/YouCompleteMe/third_party/ycmd/usr/local/bin/python3 build.py
Linux下 Vundle安装和使用 Vim实现代码跳转安装依赖Vundle是vim的一个插件管理器, 同时它本身也是vim的一个插件,可以搜索、安装、更新、清理插件。Vundle的安装需要git和curl的支持。如果没有上述两个套件可以先下载。yum install crulyum install git 安装Vundle修改~/.vimrc文件,如果你不是root用户,那么请修改对应用户目录下的.vimrc文件,比如用户名是bar,请修改/home/bar/.vimrc文件,没有.vimrc文件就创建一个。 将以下文本追加到.vimrc文件中 set nocompatible " be iMproved, requiredfiletype off " required" set the runtime path to include Vundle and initializeset rtp+=~/.vim/bundle/Vundle.vimcall vundle#begin()" alternatively, pass a path where Vundle should install plugins"call vundle#begin('~/some/path/here')" let Vundle manage Vundle, requiredPlugin 'VundleVim/Vundle.vim'" The following are examples of different formats supported." Keep Plugin commands between vundle#begin/end." plugin on GitHub repoPlugin 'tpope/vim-fugitive'" plugin from http://vim-scripts.org/vim/scripts.htmlPlugin 'L9'" Git plugin not hosted on GitHubPlugin '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 L9Plugin 'user/L9', {'name': 'newL9'}" All of your Plugins must be added before the following linecall vundle#end() " requiredfiletype plugin indent on " required" To ignore plugin indent changes, instead use:"filetype plugin on"" Brief help" :PluginList - list configured plugins" :PluginInstall(!) - install (update) plugins" :PluginSearch(!) foo - search (or refresh cache first) for foo" :PluginClean(!) - confirm (or auto-approve) removal of unused plugins"" see :h vundle for more details or wiki for FAQ" Put your non-Plugin stuff after this line用Vundle安装插件,两种方式1.打开vim然后输入 :PluginInstall ...
实习之后发现,一切代码活动都局限在一个终端界面了。由于一些安全原因和开发环境的方便,开发都是通过远程ssh到开发机上开发,自然也就只有终端界面了。VNC因为安全原因不让用,所以就别妄想使用Clion等IDE来开发了。在这样的背景下,人们大多使用VIM或者EMACS等编辑器来开发。 在调试过程中,服务端日志是一个重要的参考依据。但是这类文本并不是某种编程语言,通常查阅的时候是没有语法高亮的,而且为了对grep命令友好,通常会将一条日志打在一行里,这就使得日志信息非常密集,分辩关键信息的时候非常不方便。于是我便有了这样一个想法,编写VIM插件,对日志中的关键信息如时间戳、代码行号、错误码进行语法高亮。 为了叙述的方便,我们的目标是为下面这段日志进行高亮,将日志级别、时间戳、代码行号标识出来。 [ERROR][2017-10-01 08:08:08][example.go:231]Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sed diam eget risus varius blandit sit amet non magna. Lorem ipsum dolor sit amet, consectetur adipiscing elit.[DEBUG][2017-10-01 08:08:10][example.go:233]Lorem ipsum dolor sit amet[INFO][2017-10-01 08:09:09][example.go:2333]Lorem ipsum dolor sit amet语法高亮插件语法高亮插件需要两个.vim文件。一个是语法检测文件(ftdetect),这是为了让VIM能够将指定语法应用于指定后缀的文件。一个是语法文件(syntax),这里定义了高亮的语法和着色方案。 插件的目录结构如下: /Users/zhuangqh/.vim├── ftdetect│ └── log.vim└── syntax └── log.vim这些文件在类UNIX系统上要放到$HOME/.vim目录下,Windows系统是$HOME/vimfiles/下。 语法检测当buffer读取或创建时,将.log后缀的文件类型设置为log,之后使用log类型的语法高亮方案进行着色。 " ftdetect/log.vimau BufNewFile,BufRead *.log set filetype=log语法高亮这是文本的重点,该文件告诉VIM该怎么着色。 关键字高亮syn keyword ${group} ${keyword}大多数编程语言都有关键字。规则设置的时候,先给他一个组名,后面再接着一些关键字,之后再根据这个组名设置颜色。关键字高亮的匹配优先级是最高的,如果有其它高亮规则匹配上了也会按关键字的规则来高亮。 这个规则对我们这次任务没什么用,因为我们只想高亮日志开头的那个特定的ERROR字样,存在上下文,实际上并不是关键字。 匹配字高亮syn match ${name} ${pattern} 这个命令提供了一种强大的匹配方法,用正则表达式来匹配。我们可以用来匹配我们的时间戳,如:syn match logDate '\d\{4}-\d\d-\d\d' ...
GtagsGtags也就是GNU GLOBAL,是一个非常强大的源码符号索引工具。它通过建立索引数据库,不但可以查找函数的定义,还可以查找函数的所有引用(被调用的地方);而且它还可以增量地更新索引数据库,当代码有所改变时,它可以在很短的时间内更新索引数据库,保持索引数据库和代码同步。 韦大的 Vim 8 中 C/C++ 符号索引:GTags 篇 对 gtags 有比较详细的介绍,本文再做一些补充。 GLOBAL-6.6.3 releasedGtags的最新版本已经是6.6.3,该版本 fix了韦大文中提到的 Windows下面文件名大小写的 bug。 在 Linux上,不配置let $GTAGSCONF = '/path/to/share/gtags/gtags.conf'也可以正常工作。当项目文件的路径包含非ASCII字符时,使用pygments会报UnicodeEncodeError: 'latin-1' codec can't encode characters in position 5-8: ordinal not in range(256)自动生成Gtags索引数据库LeaderF 可以自己管理 gtags 数据库(GTAGS,GRTAGS,GPATH),它不会在你的项目目录下生成任何额外的文件或目录。gtags 数据库文件存储在$HOME/.LfCache/gtags/%PATH%OF%YOUR%PROJECT/下面, %PATH%OF%YOUR%PROJECT 是把你项目路径中的 \ 或 / 替换成 %。 只要设置let g:Lf_GtagsAutoGenerate = 1, LeaderF 就会在打开第一个文件时自动生成 gtags 数据库。当代码有更改并且已经有 gtags 数据库生成时,更改的代码会自动同步到 gtags 数据库(即使g:Lf_GtagsAutoGenerate是0)。 只有在项目根目录下有g:Lf_RootMarkers(默认值是['.git', '.hg', '.svn'])里面指定的文件或目录时,LeaderF 才会自动生成 gtags 数据库;否则只能手动生成 gtags 数据库:Leaderf gtags --update,但是当代码有更改时,gtags 数据库依然可以自动更新。 ...
安装plug (https://github.com/junegunn/v...curl -fLo /.vim/autoload/plug.vim –create-dirs \https://raw.githubusercontent…编辑/.vimrc文件(不存在,则创建)" Specify a directory for plugins" - For Neovim: /.local/share/nvim/plugged" - Avoid using standard Vim directory names like ‘plugin’call plug#begin(’/.vim/plugged’)" Multiple Plug commands can be written in a single line using | separatorsPlug ‘SirVer/ultisnips’ | Plug ‘honza/vim-snippets’" Initialize plugin systemcall plug#end()打开vim,输入:PlugInstall加载插件vim 需要开启对 python 的支持,通过以下两个方式来验证你的 vim 是否支持 python 接口,支持一种即可:echo has(“python”) " 如果你用的是 python 2.7:echo has(“python3”) " 如果你用的是 python 3.3 或者 3.4当我们打开 vim 的时候, UltiSnips 会搜寻 $VIM 路径下的所有名字为 UltiSnips 的文件夹,然后根据文档类型来寻找对应的 snips。配置$VIMexport VIM=~/.vim验证vim a.cpp,输入main。按tab键,自动补全则成功int main(int argc, char *argv[]){ return 0;}添加k8s相关snippet (https://github.com/andrewstua…,将里面UltiSnips目录下的yaml.snippets文件移动到.vim目录下的UltiSnips文件下,就可以使用了,如vim a.yamlapiVersion: v1kind: Servicemetadata: name: frontend namespace: default labels: app: someApp tier: frontendspec: ports: - port: 80 selector: app: someApp tier: frontend ...
自从接触过 spacemacs 以后,就非常喜欢它的主题:spacemacs-theme,后来照葫芦画瓢移植了一个深色背景下的 space-vim-dark。不过用了一段时间以后发现,如果白天光线非常好,使用黑色背景可能会出现反光的情况,所以就基于 vim-colortemplate 重新移植了 spacemacs-theme,这次同时支持深色和浅色背景。按照 vim-colortemplate 的说法,space-vim-theme 在加载速度上应该比之前快了一点,大概几毫秒 :(项目地址:space-vim-themedarklight上面截图中使用的 terminal 是 kitty,字体是 Iosevka Term。使用 vim-plug 安装 space-vim-theme:Plug ’liuchengxu/space-vim-theme’在 .vimrc 中启用 space-vim-theme:colorscheme space_vim_theme:h space_vim_theme 查看配置项说明。
???? 正确安装 Vundle之所以写这篇文章,其一是打算用 vim 来写 python 后端代码。笔者有两台电脑一台 PC 一台 MBP,在 PC 上安装 Vundle 插件遇到了几个坑,这里顺便写篇文章记录一下,废话不多说 let’s dive in正确安装依赖如要使用 Vundle 必须安装 Git 和 Curl,在 windows 中通常使用 chocolatey 来安装各种包,如果你没有使用过 chocolatey,首先需要安装:按照官网安装方法一步一步走即可:chocolatey 官网然后安装 Git 和 Curl,如果已经安装过则跳过这一步:C:> choco install -y gitC:> choco install -y curl这样表示安装成功Vundle 安装前的准备参考官方安装指引 Vundle on Windows首先遇到的第一个坑就是文件夹不同的命名方式:By default, Vim on Windows will still look for .vimrc and install to ~/.vim. This doesn’t work perfectly on Windows as the files aren’t hidden, but .gitignore files are used in the same manner fairly commonly. You could for example change .vimrc to _vimrc and .vim to vimfiles - this would then require a change to the example vimrc below.因为上述原因,建议将 .vimrc 改名为 _vimrc 以及 .vim 文件夹名称改为 vimfiles然后是环境变量:Additionally, if you’ve set %HOME% environmental variable to some directory, that’s the directory vim will search as ~/, thus you have to put .vimrc file and /.vim folder under the directory or remove %HOME% from environmental variable settings to use %USERPROFILE% as default.如果你修改了 %HOME% 的指向,那么你需要将其删除,并默认使用 %USERPROFILE%Vundle 开始安装进入到用户根目录,然后使用 git 命令获取 Vundle 并编辑 .vimrc 或 _vimrccd %USERPROFILE%git clone https://github.com/VundleVim/Vundle.vim.git %USERPROFILE%/.vim/bundle/Vundle.vimgvim .vimrc # 或使用 vim .vimrc打开官方指引 Quick Start-3. Configure Plugins将其中的代码全部 copy 到 .vimrc 或 _vimrc 文件中去:修改其中部分代码:set rtp+=/.vim/bundle/Vundle.vimcall vundle#begin()改为:set rtp+=$HOME/.vim/bundle/Vundle.vim/call vundle#begin(’$HOME/.vim/bundle/’)修改这个也是因为路径问题修改 .vimrc最后关闭并重新打开一个终端,修改 .vimrc 清理掉暂时不用的 Plugin:在红色箭头之间的都是我们需要安装的 Plugins,其中 Plugin VundleVim/Vundle.vim 蓝色箭头部分不可删,这个是 Vundle 管理插件的插件Plugin ‘rstacruz/sparkup’, {‘rtp’: ‘vim/’} 这个插件最好也不要删掉,如果出现错误尝试修改成 Bundle ‘rstacruz/sparkup’, {‘rtp’: ‘vim’} Trailing slash issue我们将其他插件暂且删除:修改后的文件长这样:然后 :wq 关闭文件,命令行中执行 vim安装插件准备操作完成后我们就可以去安装插件了第一种安装方式 使用 PluginInstall 命令然后执行安装 plugin 操作::PluginInstall安装过程中耐心等待出现 done 即安装完成::q 关闭然后我们尝试安装其他插件:搜索插件 :PluginSearch colorscheme选择一个你想要安装的插件,并敲击键盘 i 来安装这个插件:正在安装:安装完毕:然后选中这个插件的名称,并粘贴到 .vimrc 文件中去:关闭并退出,这样这个插件就算安装完毕了执行 :PluginList 查看我们已经安装过的插件:第二种方式 浏览 vimAwesome 网站vimawesome 网站提供了大量的不错的 vim 插件列表,可以在这个网站里搜索各种插件比如这里搜索 vim-airline,直接复制红色箭头部分的代码将代码粘贴到 .vimrc 中去然后执行 :PluginInstall 就会自动将这个插件安装好:查看效果:删除插件删除插件也很简单,首先进入到 vim 并执行 :PluginList 然后选择你想要删除的插件,并使用快捷键 shift + D,退出,打开 .vimrc 文件将你删除的那个插件从配置文件中删掉即可OK 就这么多更多好用的插件大家自己去探索吧 ...
前言vim有很多著名的grep插件,我使用过的有ack.vim,ag.vim和ctrlsf.vim,它们应该也是目前用户最多的几个了。ack.vim起步比较早,早期后端grep工具是ack,后来也支持ag(the_silver_searcher),pt(the_platinum_searcher),rg(ripgrep)等工具了。它是一个比较传统的grep插件,不支持异步,要等到grep结束后才能显示结果,在大的项目中grep会卡好一阵子。它貌似也不再维护,我N久前提交的pull request还挂在那,它最近的代码更新在11个月前。ag.vim它其实是抄袭ack.vim,没错,是抄袭。在早期ack.vim还不支持ag时,它的作者在ack.vim代码的基础上稍微改了改,支持了ag。后来被ack.vim的作者给怼了,就放弃了对ag.vim的维护。目前功能上小于ack.vim。ctrlsf.vim这是国人开发的一个插件, 后端grep工具支持ack/ag/pt/rg,同时也支持异步,不过需要Vim 8.0.1039+或者NeoVim才支持异步。这个插件很好用,在我开发Leaderf rg之前一直使用的是它。Leaderf rg顾名思义,后端基于rg,由于是LeaderF的子功能,基因上就决定它完美支持异步。同时LeaderF又是一个非著名的模糊查找插件,这使它可以在grep结果的基础上再通过模糊匹配的方式进行二次过滤,来帮助用户更快地锁定目标,这是目前上面提到的插件所不具备的。为什么选择rg(ripgrep)快速grep工具目前有ag, rg, pt, sift, ucg等。 我选择rg有以下几点原因:速度比较快,rg的README上有作者的对比,我实测也是rg快点。Windows上bug少(bug到目前还没发现),ag和pt都遇到过bug。作者很活跃,提的issue能很快得到回复。rg功能相对多些,可以从rg –help 看出来。Leaderf rg 使用介绍Leaderf rg的使用也比较简单,只要Leaderf[!] + rg命令和选项(同命令行上一样)就可以了。具体使用方法可以用:Leaderf rg -h来查看。usage: Leaderf[!] rg [-h] [-e <PATTERN>…] [-F] [-i] [-L] [-P] [-S] [-s] [-v] [-w] [-x] [–hidden] [–no-config] [–no-ignore] [–no-ignore-global] [–no-ignore-parent] [–no-ignore-vcs] [–no-pcre2-unicode] [-E <ENCODING>] [-M <NUM>] [-m <NUM>] [–max-depth <NUM>] [–max-filesize <NUM+SUFFIX?>] [–path-separator <SEPARATOR>] [–sort <SORTBY>] [–sortr <SORTBY>] [-f <PATTERNFILE>…] [-g <GLOB>…] [–iglob <GLOB>…] [–ignore-file <PATH>…] [–type-add <TYPE_SPEC>…] [-t <TYPE>…] [-T <TYPE>…] [–current-buffer | –all-buffers] [–recall] [–append] [–reverse] [–stayOpen] [–input <INPUT> | –cword] [–top | –bottom | –left | –right | –belowright | –aboveleft | –fullScreen] [–nameOnly | –fullPath | –fuzzy | –regexMode] [–nowrap] [<PATH> [<PATH> …]]optional arguments: -h, –help show this help message and exitspecific arguments: -e <PATTERN>…, –regexp <PATTERN>… A pattern to search for. This option can be provided multiple times, where all patterns given are searched. -F, –fixed-strings Treat the pattern as a literal string instead of a regular expression. -i, –ignore-case Searches case insensitively. -L, –follow Follow symbolic links while traversing directories. -P, –pcre2 When this flag is present, rg will use the PCRE2 regex engine instead of its default regex engine. -S, –smart-case Searches case insensitively if the pattern is all lowercase, case sensitively otherwise. -s, –case-sensitive Searches case sensitively. -v, –invert-match Invert matching. Show lines that do not match the given patterns. -w, –word-regexp Only show matches surrounded by word boundaries. This is roughly equivalent to putting \b before and after all of the search patterns. -x, –line-regexp Only show matches surrounded by line boundaries. –hidden Search hidden files and directories. By default, hidden files and directories are skipped. –no-config Never read configuration files. When this flag is present, rg will not respect the RIPGREP_CONFIG_PATH environment variable. –no-ignore Don’t respect ignore files (.gitignore, .ignore, etc.). This implies –no-ignore-parent and –no-ignore-vcs. –no-ignore-global Don’t respect ignore files that come from ‘global’ sources such as git’s core.excludesFile configuration option (which defaults to $HOME/.config/git/ignore). –no-ignore-parent Don’t respect ignore files (.gitignore, .ignore, etc.) in parent directories. –no-ignore-vcs Don’t respect version control ignore files (.gitignore, etc.). –no-pcre2-unicode When PCRE2 matching is enabled, this flag will disable Unicode mode, which is otherwise enabled by default. -E <ENCODING>, –encoding <ENCODING> Specify the text encoding that rg will use on all files searched. -M <NUM>, –max-columns <NUM> Don’t print lines longer than this limit in bytes. -m <NUM>, –max-count <NUM> Limit the number of matching lines per file searched to NUM. –max-depth <NUM> Limit the depth of directory traversal to NUM levels beyond the paths given. –max-filesize <NUM+SUFFIX?> Ignore files larger than NUM in size. This does not apply to directories. –path-separator <SEPARATOR> Set the path separator to use when printing file paths. –sort <SORTBY> This flag enables sorting of results in ascending order. –sortr <SORTBY> This flag enables sorting of results in descending order. -f <PATTERNFILE>…, –file <PATTERNFILE>… Search for patterns from the given file, with one pattern per line. (This option can be provided multiple times.) -g <GLOB>…, –glob <GLOB>… Include or exclude files and directories for searching that match the given glob.(This option can be provided multiple times.) –iglob <GLOB>… Include or exclude files and directories for searching that match the given glob. Globs are matched case insensitively.(This option can be provided multiple times.) –ignore-file <PATH>… Specifies a path to one or more .gitignore format rules files. –type-add <TYPE_SPEC>… Add a new glob for a particular file type. -t <TYPE>…, –type <TYPE>… Only search files matching TYPE. Multiple type flags may be provided. -T <TYPE>…, –type-not <TYPE>… Do not search files matching TYPE. Multiple type-not flags may be provided. <PATH> A file or directory to search. Directories are searched recursively. Paths specified on the command line override glob and ignore rules. –current-buffer Searches in current buffer. –all-buffers Searches in all listed buffers. –recall Recall last search. If the result window is closed, reopen it. –append Append to the previous search results.common arguments: –reverse show results in bottom-up order –stayOpen don’t quit LeaderF after accepting an entry –input <INPUT> specifies INPUT as the pattern inputted in advance –cword current word under cursor is inputted in advance –top the LeaderF window is at the top of the screen –bottom the LeaderF window is at the bottom of the screen –left the LeaderF window is at the left of the screen –right the LeaderF window is at the right of the screen –belowright the LeaderF window is at the belowright of the screen –aboveleft the LeaderF window is at the aboveleft of the screen –fullScreen the LeaderF window takes up the full screen –nameOnly LeaderF is in NameOnly mode by default –fullPath LeaderF is in FullPath mode by default –fuzzy LeaderF is in Fuzzy mode by default –regexMode LeaderF is in Regex mode by default –nowrap long lines in the LeaderF window won’t wrapIf [!] is given, enter normal mode directly.注意:如果:Leaderf后面有感叹号,会直接进入normal模式;如果没有感叹号,则是输入模式,此时可以输入字符来进行模糊匹配过滤。可以用tab键在两个模式间来回切换。Leaderf rg基本支持rg所有的必要选项,用户如果对rg命令比较熟悉,可以在vim命令行内输入:Leaderf, 然后手敲rg命令,命令选项还可以通过tab来补全。当然,更聪明的做法是定义一些快捷键。例如:" search word under cursor, the pattern is treated as regex, and enter normal mode directlynoremap <C-F> :<C-U><C-R>=printf(“Leaderf! rg -e %s “, expand("<cword>”))<CR>” search word under cursor, the pattern is treated as regex," append the result to previous search results.noremap <C-G> :<C-U><C-R>=printf(“Leaderf! rg –append -e %s “, expand("<cword>”))<CR>” search word under cursor literally only in current buffernoremap <C-B> :<C-U><C-R>=printf(“Leaderf! rg -F –current-buffer -e %s “, expand("<cword>”))<CR>” search word under cursor literally in all listed buffersnoremap <C-D> :<C-U><C-R>=printf(“Leaderf! rg -F –all-buffers -e %s “, expand("<cword>”))<CR>” search visually selected text literally, don’t quit LeaderF after accepting an entryxnoremap gf :<C-U><C-R>=printf(“Leaderf! rg -F –stayOpen -e %s “, leaderf#Rg#visual())<CR>” recall last search. If the result window is closed, reopen it.noremap go :<C-U>Leaderf! rg –recall<CR>” search word under cursor in *.h and *.cpp files.noremap <Leader>a :<C-U><C-R>=printf(“Leaderf! rg -e %s -g *.h -g *.cpp”, expand("<cword>"))<CR>" the same as abovenoremap <Leader>a :<C-U><C-R>=printf(“Leaderf! rg -e %s -g *.{h,cpp}”, expand("<cword>"))<CR>" search word under cursor in cpp and java files.noremap <Leader>b :<C-U><C-R>=printf(“Leaderf! rg -e %s -t cpp -t java”, expand("<cword>"))<CR>" search word under cursor in cpp files, exclude the .hpp filesnoremap <Leader>c :<C-U><C-R>=printf(“Leaderf! rg -e %s -t cpp -g !.hpp”, expand("<cword>"))<CR>参考:rg的glob语法。顺便说一下,直接在vim命令行敲:Leaderf rg,就会有传说中的"grep on the fly"的功能哦,同时支持fuzzy和regex两种模式。会不会支持ag等其他grep工具不会。 首先,ripgrep已经足够强大,基本不存在别的工具有而ripgrep没有的功能。其次,ripgrep有编译好的Windows、Linux和MacOS上的binary,可以在这些平台上很容易安装。再者,由于作者比较懒,不想再实现重复的功能。 ...
本文主要介绍 graphviz.vim, fork 自 wmgraphviz.vim,但是除了复用补全数据,我几乎重写了所有内容,并做了很多改进。可能很多人没用过 graphviz,它是一个开源的图可视化工具,使用 DOT 语言进行绘制,优点是可以自动布局,尤其适用于复杂的流程图,结构图等等。官方有很多示例,使用时也可以参考一些其他的优秀案例,比如:本文并不会对 graphviz 本身做太多介绍,而是分享如何在 Vim 中使用 graphviz.vim 插件方便画图。wmgraphviz.vim 是 graphviz.vim 的前身,提供了一些补全,一键编译,查看编译后文件等功能。但是使用起来感觉不是那么 fashion,很久以来也几乎没怎么更新,比如依然在于 ! 进行外部调用。graphviz.vim 整个插件非常简单,本质上就是封装了一些编译,一键查看的命令而已,主要改进包括:命令更少,配置项更简单。只有 :Graphviz 和 :GraphvizCompile 两个命令,:Graphviz 用于打开编译后的文件,:GraphvizCompile 用于编译当前文件。如果 :Graphviz! 则相当于 :GraphvizCompile | Graphviz。对于可选项,我采用了传入参数进行调控。支持 ncm2 和 coc.nvim。这个很简单,只是简单封装了下 Omni 补全以适应 ncm2 和 coc.nvim。安装使用 vim-plug 进行安装:Plug ’liuchengxu/graphviz.vim’用法:Graphviz 打开编译后的文件,文件名取自当前文件,辅以不同后缀。默认是打开 pdf 类型,比如当前打开的文件叫 foo.dot,那么 :Graphviz 是尝试打开 foo.pdf 的文件,可以传入扩展名进行指定。" 默认打开 pdf 文件" 可选项: ‘ps’, ‘pdf’, ‘png’, ‘jpg’, ‘gif’, ‘svg’:Graphviz" 打开 png 文件:Graphviz png:Graphviz! 会在目标文件不存在的情况下,尝试调用 :GraphvizCompile 进行编译然后再打开,相当于 :GraphvizCompile | Graphviz。:GraphvizCompile 用于编译当前文件,可以指定编译程序和扩展名,默认是 dot pdf。" :GraphvizCompile [exe] [format]" 默认是用 dot 编译成 pdf" :GraphvizCompile dot pdf:GraphvizCompile" 指定编译成 png 格式:GraphvizCompile png" 指定用 dot 编译成 gif 格式,实际上我没用过除 dot 的其他编译项:(:GraphvizCompile dot gif其他一些可选配置项:" 指定打开文件的命令。默认会根据平台自动选择" macOS 使用 open, Linux 使用 xdg-open 等let g:graphviz_viewer = ‘open’" 默认编译生成 pdf 格式,如果想要其他格式,将 pdf 换成其他格式即可let g:graphviz_output_format = ‘pdf’我基本只用 macOS, 所以 Windows 或者 Linux 没怎么测试过,如果遇到问题,可以到 graphviz.vim 提 issue,我会尽量解决 :(。 ...
前言上一篇文章《让人相见恨晚的vim插件:模糊查找神器LeaderF》概括性的介绍了LeaderF的基本功能,本篇对LeaderF的新功能做一下介绍。统一的命令接口随着LeaderF功能的不断增多,LeaderF的命令也在不断的增加,给开发和使用都带来一些不便。于是,LeaderF提供了一个统一的命令接口,就像shell命令一样,不同的命令选项组合,带来不同的功能。 可以通过:Leaderf -h来查看具体使用方法。usage: Leaderf[!] [-h] [–reverse] [–stayOpen] [–input <INPUT> | –cword] [–top | –bottom | –left | –right | –belowright | –aboveleft | –fullScreen] [–nameOnly | –fullPath | –fuzzy | –regexMode] [–nowrap] {file,tag,function,mru,searchHistory,cmdHistory,help,line,colorscheme,self,bufTag,buffer,rg} …optional arguments: -h, –help show this help message and exit –reverse show results in bottom-up order –stayOpen don’t quit LeaderF after accepting an entry –input <INPUT> specifies INPUT as the pattern inputted in advance –cword current word under cursor is inputted in advance –top the LeaderF window is at the top of the screen –bottom the LeaderF window is at the bottom of the screen –left the LeaderF window is at the left of the screen –right the LeaderF window is at the right of the screen –belowright the LeaderF window is at the belowright of the screen –aboveleft the LeaderF window is at the aboveleft of the screen –fullScreen the LeaderF window takes up the full screen –nameOnly LeaderF is in NameOnly mode by default –fullPath LeaderF is in FullPath mode by default –fuzzy LeaderF is in Fuzzy mode by default –regexMode LeaderF is in Regex mode by default –nowrap long lines in the LeaderF window won’t wrapsubcommands: {file,tag,function,mru,searchHistory,cmdHistory,help,line,colorscheme,self,bufTag,buffer,rg} file search files tag navigate tags using the tags file function navigate functions or methods in the buffer mru search most recently used files searchHistory execute the search command in the history cmdHistory execute the command in the history help navigate the help tags line search a line in the buffer colorscheme switch between colorschemes self execute the commands of itself bufTag navigate tags in the buffer buffer search buffers rg grep using rgIf [!] is given, enter normal mode directly.这样就可以用:Leaderf <subcommand> [options]来执行LeaderF的命令了。例如:Before Now:LeaderfFile<=>:Leaderf file:LeaderfBuffer<=>:Leaderf buffer:LeaderfMru<=>:Leaderf mru:LeaderfMruCwd<=>:Leaderf mru –cwd… 每个子命令都有专有的命令选项,可以用:Leaderf <subcommand> -h来查看。例如,Leaderf mru -h:usage: Leaderf[!] mru [-h] [–cwd] [–no-split-path] [–reverse] [–stayOpen] [–input <INPUT> | –cword] [–top | –bottom | –left | –right | –belowright | –aboveleft | –fullScreen] [–nameOnly | –fullPath | –fuzzy | –regexMode] [–nowrap]optional arguments: -h, –help show this help message and exitspecific arguments: –cwd search MRU in current working directory –no-split-path do not split the pathcommon arguments: –reverse show results in bottom-up order –stayOpen don’t quit LeaderF after accepting an entry –input <INPUT> specifies INPUT as the pattern inputted in advance –cword current word under cursor is inputted in advance –top the LeaderF window is at the top of the screen –bottom the LeaderF window is at the bottom of the screen –left the LeaderF window is at the left of the screen –right the LeaderF window is at the right of the screen –belowright the LeaderF window is at the belowright of the screen –aboveleft the LeaderF window is at the aboveleft of the screen –fullScreen the LeaderF window takes up the full screen –nameOnly LeaderF is in NameOnly mode by default –fullPath LeaderF is in FullPath mode by default –fuzzy LeaderF is in Fuzzy mode by default –regexMode LeaderF is in Regex mode by default –nowrap long lines in the LeaderF window won’t wrapIf [!] is given, enter normal mode directly.自下而上显示结果好多从ctrlp.vim转过来的朋友说不习惯LeaderF自上而下显示结果的方式,想要LeaderF也能像ctrlp一样自下而上(最优结果在最下面)显示结果,为了回馈各位朋友对LeaderF的支持,现在LeaderF也添加了自下而上显示搜索结果的功能:只需要在命令后面加上–reverse即可,或者也可以一劳永逸,在vimrc里面加上let g:Lf_ReverseOrder = 1 。And 模式LeaderF支持用空格(可以用g:Lf_AndDelimiter来修改)作为And操作符来进行模糊匹配。当匹配已经匹配到字符串末尾时,可以通过敲空格和一个子串来匹配字符串的前面部分,进行快速过滤。 NOTE: 空格分隔的每个子串都是对整个字符串的模糊匹配,而不是精确匹配。模糊匹配历史可以通过上下键来翻看模糊匹配历史:总结LeaderF精益求精,永无止境。 ...