# How do you wrap text (via a highlighter) without preceding spaces?

**URL:** <https://discuss.kakoune.com/t/how-do-you-wrap-text-via-a-highlighter-without-preceding-spaces/1745>\
**Category:** Help\
**Tags:** format, highlighter\
**Created:** [May 27, 2021, 12:31pm UTC](https://discuss.kakoune.com/t/how-do-you-wrap-text-via-a-highlighter-without-preceding-spaces/1745 "2021-05-27T12:31:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pendingcircumference](https://discuss.kakoune.com/letter_avatar_proxy/v4/letter/p/e5b9ba/32.png) [@pendingcircumference](https://discuss.kakoune.com/u/pendingcircumference)\
**Post date:** [May 27, 2021, 12:31pm UTC](https://discuss.kakoune.com/t/how-do-you-wrap-text-via-a-highlighter-without-preceding-spaces/1745/1 "2021-05-27T12:31:18Z")

</div>

When I’m working with plaintext files I frequently have long lines that I’d like to be visually wrapped. For this I do something like the following:

```auto
add-highlighter buffer/ wrap -word -width 50

```

However, that frequently results in lines that begin with whitespace as in the following example:

```auto
# Unwrapped
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec facilisis, massa in porta vehicula, nulla leo semper enim, in interdum quam nisi non erat.

# Wrapped (with the highlighter from above)
Lorem ipsum dolor sit amet, consectetur adipiscing
 elit. Donec facilisis, massa in porta vehicula,
nulla leo semper enim, in interdum quam nisi non
erat.

```

The second line starts with a space, which is really jarring. How can I make the highlighter swallow preceding whitespace?

And just to clarify: I am not interested in approaches that alter the source. I don’t want line-wrapped text in my files, just a _visually wrapped_ representation.

---

<div class="post-metadata">

**Author:** ![Screwtapello](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/screwtapello/32/12_2.png) [@Screwtapello](https://discuss.kakoune.com/u/Screwtapello)\
**Post date:** [May 27, 2021, 1:50pm UTC](https://discuss.kakoune.com/t/how-do-you-wrap-text-via-a-highlighter-without-preceding-spaces/1745/2 "2021-05-27T13:50:03Z")

</div>

That’s not currently possible.

Kakoune’s soft-wrapping can insert extra characters that cursor-movement skips (a line-break, an optional indent and an optional wrap-marker), but it cannot hide characters (like extra whitespace). The wrap-marker could be updated to leave the whitespace at the end of the previous line instead of wrapping it to the next, but people would be annoyed if a word that _could_ fit on the previous line was wrapped just because it had a trailing whitespace character (or fifty) that pushed it over the limit.

It might be possible for the wrap highlighter to abbreviate wrapped whitespace in a similar way to how the `replace-ranges` highlighter works - if any selection ever overlaps part of the concealed text, it is revealed. However, I don’t know how invasive a change that would be to the codebase.

---

<div class="post-metadata">

**Author:** ![pendingcircumference](https://discuss.kakoune.com/letter_avatar_proxy/v4/letter/p/e5b9ba/32.png) [@pendingcircumference](https://discuss.kakoune.com/u/pendingcircumference)\
**Post date:** [May 27, 2021, 3:24pm UTC](https://discuss.kakoune.com/t/how-do-you-wrap-text-via-a-highlighter-without-preceding-spaces/1745/3 "2021-05-27T15:24:11Z")

</div>

Ah thanks for the extensive reply. It’s quite a shame that it’s not possible but at least I know now.

Do you know if there are any plans to make this possible in the future?

---

<div class="post-metadata">

**Author:** ![Screwtapello](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/screwtapello/32/12_2.png) [@Screwtapello](https://discuss.kakoune.com/u/Screwtapello)\
**Post date:** [May 29, 2021, 2:27am UTC](https://discuss.kakoune.com/t/how-do-you-wrap-text-via-a-highlighter-without-preceding-spaces/1745/4 "2021-05-29T02:27:14Z")

</div>

I don’t know of any plans to make that possible, no.
