Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim: showing listchars changes the screen wrapping

I noted that when I show up the EOL listchars in a text the linebreaks are losen

p.e.

 this is my text of this 
 message

becomes after set list ..eol

 this is my text of this mess
 age(EOL CHAR)

I would like to see the EOL characters without breaking the words at window border. Is that possible?

like image 460
remio Avatar asked Mar 18 '10 15:03

remio


1 Answers

Unfortunately it sounds like this is a documented limitation of Vim. From the documentation of linebreak (the option which causes per-word line breaks instead of per-character):

This option is not used when the 'wrap' option is off or 'list' is on.

Alternate solution: highlight end-of-lines. The simple one-time way would be to just search for them (/$). Beyond that, you can use highlighting:

:highlight endofline ctermbg=Green
:match endofline /$/

That'll give your EOLs green backgrounds. See :help highlight-args for more on how you can specify the highlight.

Original answer

This is not the OP's actual problem, but could sometimes happen, so I'll leave it here for others to find when they search.

From the help on 'list':

Note that list mode will also affect formatting (set with 'textwidth' or 'wrapmargin') when 'cpoptions' includes 'L'. See 'listchars' for changing the way tabs are displayed.

From the help on 'cpoptions':

L    When the 'list' option is set, 'wrapmargin', 'textwidth', 'softtabstop' and Virtual Replace mode (see |gR|) count a as two characters, instead of the normal behavior of a .

'cpoptions' is all about vi-compatibility - are you launching vim as vi? Or are you manually setting any of those flags? Check the output of echo &cpoptions, be sure to launch as vim, and if it's still set (no idea why it would be) you can unset the flag (set cpoptions-=L).

And of course, make sure that the settings for wrap, wrapmargin, linebreak, and textwidth are what you want.

like image 55
Cascabel Avatar answered Sep 30 '22 13:09

Cascabel