4
votes
How to jump between matching HTML/XML tags?
The xmledit (http://vimawesome.com/plugin/xmledit) plugin allows to jump between open and close tags using
<localleader>%
Often <localleader> will be \, so you can jump with
\%
NOTE: Unlike ...
3
votes
Conversion from XML to KML
Think of the macros! Really, the regexps by Tumblr41 and Jair Lopez are freakishly smart, but can you really reproduce that in a different case in acceptable time? Here's how I would do it (cursor on ...
3
votes
Accepted
Conversion from XML to KML
I've come up with a search and replace function that should work for you:
:%s/\(\s*\)<Latitude>\(-\=\d\+\.\d\+\)<\/Latitude>\_.\s*<Longitude>\(-\=\d\+\.\d\+\)<\/Longitude>/\1&...
3
votes
Accepted
How to remove line breaks in xml tags?
Here is a solution which is not perfect but not that bad:
First add these lines to your .vimrc:
function! ReJoinTags() range
set nowrapscan
let @/='<\(\k\+\)>\([^<]\|\n\)\{-}<\/\...
2
votes
How to format xml or html's attributes into multiple lines instead of lining up on one line?
The suggested solution didn't work for me. formatprg_args_expr_xml is no longer recognized in the current version (at 713e7c2).
I solved the issue by adding these two lines in my .vimrc.
let g:...
2
votes
Accepted
Linewise inner tag without the tag lines?
You can use Operator-pending mode to define new text objects by having
the mapping invoke Visual mode, and then select the text you want to
operate on.
I'm not entirely sure what semantics you want ...
2
votes
Linewise inner tag without the tag lines?
You are right, vim treats tags differently. The plugin vim-indent-object will help you, you can do <ii with it to chance the indent of all lines inside the same indent block.
2
votes
xml ftplugin overrides textwidth
Yes, the xml filetype plugin disables auto wrapping text using textwidth with the following:
setlocal formatoptions-=t
This removes the option t (= "Auto-wrap text using textwidth") from ...
2
votes
Why is my XML filetype configuration overridding my PHP filetype configuration?
The PHP filetype loads the HTML filetype; from $VIMRUNTIME/syntax/php.vim (around like 63):
runtime! syntax/html.vim
unlet b:current_syntax
This is because PHP is layered "on top" of HTML, and you ...
2
votes
Accepted
Is there an instant way of editing matching inner tags?
text-object (say mt) that selects the name of matching tags?
It's hard to think about handling this one with a text object, because a text object is all about selecting some text and then the ...
2
votes
Is there an instant way of editing matching inner tags?
I found that something like that is possible with the plugin tpope/vim-surround.
<di█ id="foo">
<div class="bar">
</div>
Or:
<div id="foo">
█ <div class="bar">&...
2
votes
Accepted
Replace all self-closing xml tags with open and close tags
You could use the following substitution command:
:%s%<item[^>]\{-}\zs */>\ze%></item>%g
In this case I use % as separator instead of /. That way I need less escaping.
To explain ...
1
vote
Vim autoindent and xml self-closing
Thats was a bug. Thanks to @ChristianBrabandt who solved it very quickly.
https://github.com/chrisbra/vim-xml-runtime/issues/25
1
vote
Replace all self-closing xml tags with open and close tags
So after doing some more research I came up with something that is able to do this:
:%s/<item \(.*\)\/>/<item \1 >\r\t<something>text<\/something>\r<\/item>
1
vote
Accepted
Find and replace in XML file in vi
Try:
:g/lang="EN"/s%^\(.\{-}\)\(<span .\{-}</span>\)%\1\2\2%|s%lang="EN"%lang="FR"%
Breakdown:
g/lang="EN"/ for all lines that contain lang="EN"
s%^\(.\{-}\)\(<span .\{-}</span>\)%...
1
vote
Return cursor to an initial position after pasting text from a function
DBK already show you how to fix it, so i explain only why your approach doesn't work here.
From :h feedkeys() :
The function does not wait for processing of keys contained in {string}.
To show ...
1
vote
Accepted
Run vimscript function only once although v:count1 > 1
There are two <para> because you apply v:count1 to every tag you render. Try this:
function s:DocbkPrintTag(tag)
" apply v:count1 to the outside tag
put =repeat(s:DocbkRenderTag(a:tag),...
1
vote
Accepted
How do I move to the beginning of a visual block from a vimscript function?
Simply?
normal! '<
However, I would highly recommend seeing if there is a way to accomplish what you want via simpler (Ex) commands. If you need to do some work over a range, Ex commands are good ...
1
vote
Accepted
Vim does not spellcheck the content of <title> element in my DocBook files
I assume that spell check also doesn't work in <emphasis>, <remark>, <comment> and <citation>.
The syntax file for DocBook is rather old (2012) and I don't know if it is still ...
1
vote
Accepted
How do I remove newlines inside arbitrary xml tags matching a pattern?
First off, I never knew that you can have a search in the range. Thanks for making me learn something new!
Second off, you were really close with :g/<line/,/\/>/join. But I'm pretty sure that ...
1
vote
Accepted
Make UltiSnips perform XML encoding on tabstop text
Using regular expression snippet it's possible to achieve this. Following snippet works almost ideally:
snippet "keystroke([^>]\S+)?" "Adds keystroke" r
<keystroke>`!p snip.rv = (match.group(...
1
vote
Conversion from XML to KML
If the XML file only have lines in that format you could try this shorter command:
:%s/\v\S{-}([0-9.-]+)\_.{-}([0-9.-]+)\S*/<Point><coordinates>\2,\1<\/coordinates><\/Point>
...
1
vote
How to jump between matching HTML/XML tags?
A relatively new and popular plugin vim-matchup provides quite extensive support as long as there is syntax highlighting for the language, HTML included.
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
filetype-xml × 27vimscript × 6
formatting × 5
indentation × 3
functions × 3
filetype-html × 3
regular-expression × 2
cursor-movement × 2
spell-checking × 2
wrapping × 2
vimrc × 1
key-bindings × 1
syntax-highlighting × 1
search × 1
command-line × 1
substitute × 1
normal-mode × 1
visual-mode × 1
cursor-motions × 1
replace × 1
folding × 1
macro × 1
plugin-ultisnips × 1
line-breaks × 1
multiple-lines × 1