I'm using vim with pandoc and need to use non-breaking spaces fairly regularly, which is achieved in pandoc by backslash-escaping a regular space (i.e., "\ "). I would prefer to use hard line breaks in vim, but when I do so and a non-breaking space occurs at the end of a line, the space character is deleted and the backslash remains at the end of the line -- and this signals the end of the paragraph to pandoc.
Is there a way I can tell vim to treat "\ " as a printed character when it reformats paragraphs with hard line breaks?
As an example, if I write the following:
This line contains a non-breaking space\ because I don't want a break after space.
What I want vim to do is this:
This line contains a non-breaking
space\ because I don't want a break after
space.
But what it does is this:
This line contains a non-breaking space\
because I don't want a break after space.
My workaround for the moment is to stick to soft line breaks, and I've remapped h
to gh
etc. to make that easier to deal with. I'm also trying to figure out whether there is an alternative way to specify a non-breaking space to pandoc that will be less confusing to vim.
Use the proper UTF-8 character for a non-breaking space (U+00A0) instead of \
. In Vim, you can insert it with Ctrl-v x a 0
.
In your ~/.vimrc
file add the following to highlight non-breaking spaces:
set list
set listchars=nbsp:.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With