其他分享
首页 > 其他分享> > vim自动关闭标签

vim自动关闭标签

作者:互联网

在这里插入图片描述

一行代码搞定

inoremap <buffer> <C-s> <esc>yiwi<lt><esc>ea></><esc>hpF>i

这个适用于不喜欢安装太多vim插件的小伙伴。
参考:
https://www.reddit.com/r/vim/comments/gu5nm0/automatically_close_jsx_tags/

vim-closetag插件

https://github.com/alvan/vim-closetag

我在html中测试正常使用,但是在*.js的文件中的JSX 标签无法正常使用,不清楚是我的配置问题还是什么问题。研究了一下也没有搞定

coc-snippets代码段

因为我本人是使用nvim-coc的
项目地址:
https://github.com/neoclide/coc.nvim

然后我在coc中又安装了这个coc-snippets插件
项目地址:
https://github.com/neoclide/coc-snippets
后来发现使用自定义代码段的方式,也可以很方便的实现。

使用方法:
指令
使用:CocList snippets以开放的片段列表。
使用:CocCommand snippets.editSnippets以编辑用户片断当前文件类型的。
使用:CocCommand snippets.openSnippetFiles当前文件类型的开放代码片段文件。

比如:我在js里写react native代码,想实现Text自动关闭标签,我的操作如下:

  1. :CocCommand snippets.editSnippets
  2. 在代码段中加入:
snippet Text "RN Text" b
<Text>${1}</Text>
endsnippet
  1. 使用方法在代码中输入Text自动会触发代码段

标签:https,标签,代码段,vim,coc,关闭,com,snippets
来源: https://blog.csdn.net/lxyoucan/article/details/117025199