I have an xml file with some text which is so long, that it does not fit into the normal line of my editor.

Is there an xml-specific way to insert a newline just for formatting, i.e. ignored by a correct xml parser?

Thank you in advance.

closed as off-topic by statox, jecxjo, akshay, Karl Yngve Lervåg, EvergreenTree Oct 26 '16 at 1:57

  • This question does not appear to be about Vi and Vim family of editors, within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • I'm not sure what you are looking for exists. Standard XML does not contain a built in way to describe its own representation. Unless extended to do so (kinda like html... kinda). Seeing as this site is for VI and VIM you will get editor specific answers to this question, therefore you may have a better chance of getting what you want out of this question by re-asking it on stack overflow. Otherwise if using vim Statox's answer is correct way of doing what you ask in the VI and VIM editors. – Archangel33 Oct 24 '16 at 13:53
  • 4
    I'm voting to close this question because it appeared that OP isn't looking for a solution in vim but a generic solution to modify an XML file which makes this question off-topic. – statox Oct 24 '16 at 15:55

You're looking for :h 'wrap':

This option changes how text is displayed. It doesn't change the text in the buffer, see 'textwidth' for that.

When on, lines longer than the width of the window will wrap and displaying continues on the next line. When off lines will not wrap and only part of long lines will be displayed. When the cursor is moved to a part that is not shown, the screen will scroll horizontally.

Simply add this line to your vimrc:

set wrap

Or to use wrap only on xml buffers:

autocommand FileType xml setlocal wrap

(See :h :setlocal)

  • hm,... i am not looking for a tool specific solutions for not displaying a newline or not. – user2609605 Oct 24 '16 at 13:22
  • @user2609605 Setting the wrap option will make long lines appears as several lines on your screen while keeping them as one line on the actual code, isn't it what you're looking for? – statox Oct 24 '16 at 13:24
  • 2
    To the light of @Archangel33 's comment I understand your comment now i am not looking for a tool specific solutions then indeed you're not on the right site. – statox Oct 24 '16 at 14:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.