5 ms·
<!-- Ugh. Surround is OK, but sucks for wrapping in HTML tags. If I select the line: --> Hello! <!-- And use stp (surround selection with <p/>) I get: -->
by thomasmallen 18y ago
<!-- Ugh. Surround is OK, but sucks for wrapping in HTML tags. If I select the line: -->
Hello!
<!-- And use stp (surround selection with <p/>) I get: -->
<p>
Hello!
</p>
<!-- Instead of -->
<p>Hello!</p>
<!-- The workaround? ^v$ which is tedious. I recommend mapping this for those times when you want to wrap the current line quickly in XML tags.
function! TagWrapper()
let a:tag = input("Tag: ")
normal `>
exe "normal a</" . a:tag . ">"
normal `<
exe "normal i<" . a:tag . ">"
endfunction
-->
- pkrumins 18y agoThis plugin does not define 'stp'. You must be using some other plugin that has this mapping. The plugin I wrote about wraps HTML around perfectly. Try: ysiWt<p> Or if you knew the tag you were going to wrap your "Hello!" in, then in insert mode you could have pressed: <CTRL+s>t<p>.
- thomasmallen 18y agoNo, the plugin does define stp. :help Surround The pattern you have there ("ysiWtp", < is unnecessary, as is >) is actually not thoroughly tested (as mentioned in the docs) and is used when not in a visual selection. In a visual selection, you use "s" followed by what you want to surround with, e.g. s"
- pkrumins 18y agoYou must have a different surround.vim script. Perhaps someone else wrote a script and called "surround.vim" as well. The one I am talking about does not define stp and requires < > between tags. What does your 'stp' do? Edit: I see what you did there. You were in visual mode!
- thomasmallen 18y agoOf course. surround.vim couldn't get away with clobbering "s" in normal mode.
- pkrumins 18y agothis works for me: viwstp> turns foo into <p>foo</p> Edit: (30 mins later) Now I understood fully what was happening. ;)