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 ...
Boris Brodski's user avatar
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 ...
PhilippFrank's user avatar
  • 1,225
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&...
Tumbler41's user avatar
  • 7,746
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\)\{-}<\/\...
statox's user avatar
  • 49.7k
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:...
Andrew-Dufresne's user avatar
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 ...
Antony's user avatar
  • 2,570
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.
Philippos's user avatar
  • 294
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 ...
Ralf's user avatar
  • 9,187
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 ...
Martin Tournoij's user avatar
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 ...
filbranden's user avatar
  • 28.8k
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">&...
lpf's user avatar
  • 43
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 ...
Ralf's user avatar
  • 9,187
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
Maïeul's user avatar
  • 121
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>
Seth's user avatar
  • 43
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>\)%...
Ralf's user avatar
  • 9,187
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 ...
dedowsdi's user avatar
  • 6,248
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),...
dedowsdi's user avatar
  • 6,248
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 ...
D. Ben Knoble's user avatar
  • 26k
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 ...
Ralf's user avatar
  • 9,187
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 ...
DJMcMayhem's user avatar
  • 17.5k
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(...
grodzik's user avatar
  • 4,598
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> ...
Jair López's user avatar
  • 1,854
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.
xji's user avatar
  • 214

Only top scored, non community-wiki answers of a minimum length are eligible