Reputation: 291
Here are 2 :s commands. Work fine at command line or as part of a key mapping, but I cannot get them to run correctly in a vim script. I've used normal, execute, execute "normal..." and call normal on them. I've put the range with the s, and before normal, I've tried them with and without a : before the s. How should I write them within a .vim file?
:%s/<[\/]\?SPAN\|DIV\|OPTION[^>]*>//gi
:%s/<\(hr\|h[1-6]\|ul\|li\|p\|tt\|ol\|table\|tr\|td\|p\) [^>]\+/<\1/gi
Upvotes: 1
Views: 218
Reputation: 53654
You should just add them to a script. You don’t have to prefix them with anything in this case.
Upvotes: 0
Reputation: 172698
You can put Ex commands like yours into a myscript.vim
file, then execute the commands via
:source myscript.vim
This should work without modifications (you don't need the leading :
, but it doesn't hurt). I don't see any problems, and you don't need :execute
unless you want to include variables. :normal
is for normal-mode commands (like diw
, for example).
Typically, you'd place those custom commands into a function, though (which would be placed in ~/.vimrc
or ~/.vim/plugin/myscript.vim
), and invoke it via :call
, either directly, via a mapping, or custom command.
Upvotes: 2