VIM:如何将search / replace命令添加到vimrc并映射到快捷方式 [英] VIM: how to add search/replace command to vimrc and map to a shortcut
问题描述
:%s!<!\& lt; !>!\& gt!!g
我想要一种方法,我可以映射两者这些命令一起运行...我在vimrc中做了一些搜索如何使用:map
命令,但是我看不出如何组合两行进入单个命令(或单个笔画序列)运行的单个命令。
谢谢!
您可以将命令放在一条单独的行上,用条形分隔。
:%s!<!\& lt;!g |%s!>!\& gt;!g
但是您必须在地图中转义它
命令
:map&F3 :%S< \&安培; LT; g\ |:!!!%S取代; \&安培; GT; G< CR>
I have two search/replace commands that I find myself running in vim fairly often to clean up html code so I can copy/paste it online. The commands are:
:%s!<!\<!g
:%s!>!\>!g
I wanted a way I could map both of these commands to be run together ... I did some searching for how to use the :map
commands in vimrc, however, I can't see how to combine the two lines into a single command that is run with a single keystroke (or a single sequence of strokes).
Thanks!
You can put the commands on a single line separated with a bar.
:%s!<!\<!g|%s!>!\>!g
But you'll have to escape it in the map
command
:map <F3> :%s!<!\<!g\|:%s!>!\>!g<CR>
这篇关于VIM:如何将search / replace命令添加到vimrc并映射到快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!