你知道Notepad++有这样的功能吗,当您单击一个标签(比如 )时,它会自动突出显示结束标签()?这个功能叫什么?如何调整Vim以具备此功能?
还有什么其他方法可以将Vim转变为强大高效的HTML编辑器?
还有什么其他方法可以将Vim转变为强大高效的HTML编辑器?
使用标签包装所选文本:
function! VisualTagsWrap()
if !exists('g:tags_to_wrap')
let g:tags_to_wrap=[]
endif
let g:tags_to_wrap=split(input('space separated tags to wrap block: ', join(g:tags_to_wrap, ' ')), '\s\+')
if len(g:tags_to_wrap)>0
execute 'normal! `>a</'.join(reverse(g:tags_to_wrap), '></').'>'
execute 'normal! `<i<'.join(reverse(g:tags_to_wrap), '><').'>'
endif
endfunction
vnoremap <silent>,w <ESC>:call VisualTagsWrap()<CR>
为标签突出显示闭合括号:
set matchpairs+=<:>
虚拟文本(在插入模式下键入“lorem”):
inoreabbrev lorem Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
vi<
那样在一对标签之间进行可视化选择。 - asfallowscit
命令来更改标签,例如 haha(也可以使用 vit
)。 - Jay匹配标签:
可以使用matchit插件来实现。Vim 6及以上版本已经默认安装了matchit.vim插件。要安装matchit,请阅读:help matchit-install
。
确保在vimrc中添加了filetype plugin on
。
安装完成后,使用%
来匹配开始/结束标签。要获取更多帮助,请查看:help matchit-intro
。
matchit.vim
包含在 vim-common
软件包中。然后将以下内容添加到您的 ~/.vimrc
文件中,以使其正常工作:
source /usr/share/vim/vim73/macros/matchit.vim
接着只需按下 Shift+5
(也就是 %
) 即可跳转到匹配的标签。
如果编辑没有 .html 后缀的 HTML 文件,请使用以下命令:
:set filetype=html
来激活 matchit 宏。
Emmet。只需使用vim-emmet。它有一些很酷的杀手级功能。您只需编写nav
,然后<ctrl + y> ,
(ctrl
+ y
,然后,
)即可自动执行<nav></nav>
。 .myclass
,然后<ctrl + y> ,
,然后您会得到<div class="myclass"></div>
。最重要的是,键入html:5
,然后按ctrl + y
,然后,
,您将获得设置好的HTML文档。