peateasea,
@peateasea@mastodon.social avatar

Some editors seem to randomly insert non-breaking spaces. This can be a pain. In replace them with normal spaces like so:

:%s/<Ctrl-V>u00a0/ /g

where u00a0 is the utf-8 sequence for a non-breaking space.

peateasea,
@peateasea@mastodon.social avatar

I decided to write this up with more details. Doing so helped deepen my understanding and hopefully it helps others too.

https://peateasea.de/breaking-spaces-in-vim/

ferki, (edited )
@ferki@fosstodon.org avatar

@peateasea To make vim show non-breaking spaces as something else, configure it with something like:

set listchars=nbsp:‗

Then the :set list command shows the ‗ (double low line) character in place of each non-breaking space without actually replacing it in the file, making it easier to spot for humans.

Use the same to also reveal other normally invisible or hard to spot characters and situations (tabs, trailing/leading spaces, long lines continuing off-screen, etc.)

Happy hacking! :)

  • All
  • Subscribed
  • Moderated
  • Favorites
  • vim
  • kavyap
  • thenastyranch
  • ethstaker
  • DreamBathrooms
  • osvaldo12
  • magazineikmin
  • tacticalgear
  • Youngstown
  • everett
  • mdbf
  • slotface
  • ngwrru68w68
  • rosin
  • Durango
  • JUstTest
  • InstantRegret
  • GTA5RPClips
  • tester
  • cubers
  • cisconetworking
  • normalnudes
  • khanakhh
  • modclub
  • anitta
  • Leos
  • megavids
  • provamag3
  • lostlight
  • All magazines