Vim 插件、扩展

开发

vim 插件开发入门之 MRU - 知乎open in new window

git

插件是对当前打开文件操作

:git rm &
:gremove

:git mv & target-path
:gmove target-path

:git add &
:gwrite

:git checkout &
:gread

gvdiff 检查变动

:Gstatus
-
=

注释 - nerdcommenter

leader c space 注释或取消注释
leader c y 先复制再注释
leader c A 行末尾追加注释
leader c s 多行带星号(sexy)注释
leader c m 单行带星号(minimal)注释

FZF

Preview 我用的命令是bat,自动语法高亮

使用理由:全局性 zsh git What am I missing by not using FZF? : vimopen in new window

wildfire

选择内容时向外扩展, enter 即可 只要有界限就能放到里面选择,如各种括号

markdown

  • :Toc 临时跳转窗口
  • :gentoc 在光标位置生成目录,可放到标题上按t)跳转,按ctrl - o跳回

emmet

插件默认触发补全键是ctrl y ,

期望是用 tab ,而原 tab 功能由\tab替代

ctrlp 刷新索引

ctrl - p F5

nerdtree

  • 存在时,按q关掉,再ctrl-p,或者找到文件按t在新标签中打开
  • 操作当前文件,如重命名:NERDTreeFind
  • 切换显示隐藏 shift i
  • 重命名等操作,nerdtree 模拟的是文件管理器的右键(这一点不如原生文件浏览方便)
    (a)dd a childnode
    (m)ove the curent node
    (d)elete the curent node
    (c)copy the current node
    
  • u: 切换目录树的根目录为上层目录
  • U: 切换目录树的根目录为上层目录,并保持旧的目录树的状态

:UltiSnipsEdit

tab 补全
ctrl-b 下一个点
ctrl-z 上一个点

临时使用其它类型的补全,设置文件类型

ternjs 是 JS 代码分析引擎

自动完成|函数参数提示|查询表达示类型|查找定义|自动重构(改名)

:h tern_map_keys

LeaderF

ctrl f 切换路径搜索和名字搜索,名字不惟一时,适合路径查找,如果输入关键词后,内容很多,按些键切换模式 ctrl u 清除,重新输入关键字 'ind;mock' 文件名加目录名 'ind js' 多个关键字匹配文件名

创建便携 vim

bash <(curl -L https://raw.githubusercontent.com/junegunn/myvim/master/myvim)

会创建可执行文件,所它放到需要的机器,添加执行权限运行即可 Creating portable Vim environmentopen in new window

coc

dotfiles/.vimrc at master · vuhuucuong/dotfilesopen in new windowA guide to modern Web Development with (Neo)vim – freeCodeCamp.orgopen in new window

jarvis/init.vim at master · ctaylo21/jarvisopen in new window

配合 snip

ctrl-y

Completion with sources · neoclide/coc.nvim Wikiopen in new window

指定类型使用,markdown 打字卡

Disable coc.nvim per filetype (i.e. a filetype whitelist or blacklist) · Issue #349 · neoclide/coc.nvimopen in new window

" Remap for rename current word
nmap <F2> <Plug>(coc-rename)

init.vimopen in new window

:CocInstall coc-explorer

定义跳转 GoTo 查看 ~/.vimrc

note plugin

正面观点

  • 方便导航
  • 思维导图形象,但搜索差,不宜保存长久笔记
  • 设置多个 wiki
= My knowledge base =
    * [Tasks](Tasks) -- things to be done _yesterday_!!!
    * Project Gutenberg -- good books are power.
    * Scratchpad -- various temporary stuff.

How does vimwiki compare to emac's org mode? : vimopen in new windowvimwiki cheatsheetopen in new windowHow I Take Notes With Vim, Markdown, and Pandoc - things james doesopen in new window将 vim 作为日常笔记本使用 – VOID001's WOWOopen in new window

反面观点

认为不需要 vimwiki

查找,#后向匹配,g*非精确匹配

Coc Typescript

Vim for JavaScript and React in 2019 | Vim From Scratchopen in new window

按键功能
gd跳转定义
gy跳转类型定义
gi跳转实现
gr跳转引用
leader ac代码动作
leader a可视模式,已选代码动作
leader qf修复当前
K查看文档
c-j插入模式,snip 展开

Coc snippets

c-j 展开 c-j``c-k 上、下一个编辑点

查看当前 buffer 关联 :CocList snippets

可以不安装 ultisnips

问题:编写 useS 可自动 import,但是对编辑点支持有限 解决:为了使用 virtual placeholder,改用 ultisnips + coc-ultisnips,不使用 coc-snippets

react snippets 位置 ~/.vim/plugged/vim-snippets/UltiSnips/javascript_react.snippets

表格支持

junegunn/vim-easy-align

<leader>\ Align GitHub-flavored Markdown tables

插件 dhruvasagar/vim-table-mode: VIM Table Mode for instant table creation.open in new window

使用:

leader tm

||输入分割线

csv 转换 leadet tt

```
h,h,h
||
a,a,a

a,b
--
c,d
e,f
```
:[range]w !eslint --stdin

vim-task

  • 简单专注,不用离开 Vim
  • 快捷键
    n/N 创建
    d(one) 切换完成
    x(cancel) 取消
    a(rchive) 存档
    

翻译

:Translate -w test

VIM 插件推荐 - 知乎open in new window

fugitive

为什么用,命令行 git blame 需要记住文件名、行数 Gmove 处理了 buffer,避免返回时修改原文件 完整实现 The Fugitive Series - a retrospectiveopen in new window

  • md new todo
    au Filetype markdown set com=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,b:-\ \[\ \]
    au Filetype markdown set formatoptions=tcroqln
    
    会影响原功能-,暂时使用复制吧

字符包围

  • 单词两侧加空格 ysiw<space><space> 分解:you surround inner word with space
  • y 是添加包围符的动作,注意空格打两个
  • 拓展,如何删除两边空格,ds<space><space>
  • 小写 s 表示不同行,同行使用大写 S
  • 查看帮助:h surr<tab>

ctrlsf

搜索、查看、编辑

GLOB search :CtrlSF -G *.pug svg 在所有 pug 文件中,查找 svg

插件一般不支持工具的原生命令行参数,如果要用完整命令行,Leaderf rg

tmp

  • set spell 拼写检查,比如记不清楚某个单词拼写,可以新开 buffer,然后 z=num <cr>
Last Updated:
Contributors: gongyi01