[vim/vim] Soft wrap width option (#1847)

297 views
Skip to first unread message

WillDHB

unread,
Jul 16, 2017, 8:35:24 PM7/16/17
to vim/vim, Subscribed

When using the "wrap" option, it would be convenient to be able to specify a width (comparable to the textwidth option for hard line wrapping) rather than tying the soft wrap to the window width.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub

Daan Wynen

unread,
Feb 11, 2019, 8:44:04 AM2/11/19
to vim/vim, Subscribed

There is quite a bit of demand for this, actually.

Over at neovim: neovim/neovim#4386
On stackoverflow: https://stackoverflow.com/questions/989093/soft-wrap-at-80-characters-in-vim-in-window-of-arbitrary-width

I also came here after searching for a solution, and there just doesn't seem to be one, really.
My use case is writing latex (i.e. text, not code) using the terminal in i3wm.
I use multiple windows within vim, but each is usually >>80 chars wide, which makes text unnecessarily hard to write and navigate. Since the terminal usually fills all the screen (as in any tiling window manager) resizing the terminal is a bit uncomfortable.

Jakub Łukasiewicz

unread,
Aug 1, 2022, 12:21:39 PM8/1/22
to vim/vim, Subscribed

Continuation of #10825

@brammool

Yes, if you can't change the Vim window width, then splitting vertically
does that. You can leave the window on the right empty, then you simply
have the vertical separator as the boundary. That's not really a
problem, is it?

It only works if I have only one vertical window.
If I want to have two vertical windows, then I need to resize both and add third for padding.
If I want to have two vertical windows and second one starting at half of the screen, I need 2 padding windows:

| <- 80 -> | <- 25 -> | <- 100 -> | <- 6 -> |
| ~~~~~    | XXXXXXXX | ~~~~~     | XXXXXXX |
| ~~~      | XXXXXXXX | ~~~       | XXXXXXX |
|          | XXXXXXXX | ~  ~~~~   | XXXXXXX |
| ~~~~~~   | XXXXXXXX |           | XXXXXXX |

And of course, every other :vnew or :resize will ruin the layout.
Additionally, window navigation also is more annoying, since instead of <C-w>l, not it would need to be <C-w>l<C-w>l.
It also shrinks statusline and tabline, while I would like them to remain unchanged.

@arp242

Using set columns=80 works reasonably well btw, although it will be reset on a window resize. Can probably use an autocmd for it.

This solution has essentially all drawbacks of padding window, but now also requires handling that option ("also", because padding windows are unavoidable for slightly complex layouts than one window).


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/1847/1201421538@github.com>

Jakub Łukasiewicz

unread,
Aug 1, 2022, 12:25:18 PM8/1/22
to vim/vim, Subscribed

I'll also allow myself to quote a reply from neovim/neovim#4386 by @ZyX-I:

  1. This taints window navigation, also some plugins: e.g. aurum when committing by default displays diff in the biggest window adjacent to commit one, this will much likely be “wrap” window.
  2. This solution shrinks status line. Also do not forget that something needs to be done to border window’s status line.
  3. This solution makes some :windo commands more complex, and if one hides the presence of windows it is easy to forget to add an if.
  4. This solution will hide all ~ characters, not only characters in the border window, making it impossible to see where file ends without &number or something like this.
  5. This solution will hide all window borders.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/1847/1201426104@github.com>

Artii4

unread,
Aug 5, 2022, 3:51:07 PM8/5/22
to vim/vim, Subscribed

This feature would be really nice especially when working with TeX or markdown, where you don't want the editor to insert actual line break.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/1847/1206804950@github.com>

Jakub Łukasiewicz

unread,
Aug 7, 2022, 1:30:50 PM8/7/22
to vim/vim, Subscribed

Tying it to textwidth? That's not so bad of an idea.
It would definitely easier the implementation as it would essential require only two lines of code (excluding braces and comments + formality of adding the boolean option itself).

Perhaps I will try to cook up such PR myself some time later.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/1847/1207451508@github.com>

Jakub Łukasiewicz

unread,
Nov 22, 2022, 5:09:32 PM11/22/22
to vim/vim, Subscribed

Some idea would be to have an option wrapwidth which would control at what width the wrapping would occur.
Its values could have the following meaning:

  • 0 - use window width
  • positive number - "at that column regardless of window width"
  • negative number - "at that column, unless window narrower"


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/1847/1324298582@github.com>

arisolt

unread,
Jan 4, 2023, 11:44:18 PM1/4/23
to vim/vim, Subscribed

Bumping this, as it would make life considerably better for people using vim to write long form text (inlcuding personal wikis), because we often deal with long paragraphs and depending on the dimensions of the terminal screen for soft wrapping is not ideal.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/1847/1371775751@github.com>

Message has been deleted

rickhowe

unread,
Oct 9, 2023, 5:29:00 AM10/9/23
to vim/vim, Subscribed

I have found that vim post-9.0 patches and nvim 0.10.0 have a inline virtual-text feature to realize this. I tried to implement the plugin. Hope to help you.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/1847/1752640386@github.com>

Jakub Łukasiewicz

unread,
Oct 9, 2023, 8:14:26 AM10/9/23
to vim/vim, Subscribed

@rickhowe Nice!
I've actually prototyped something similar: softWrapLineAtCol.vim.
Have a look if anything could be of use to improve your plugin.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/1847/1752896026@github.com>

Shane-XB-Qian

unread,
Oct 9, 2023, 10:25:13 AM10/9/23
to vim/vim, Subscribed

@rickhowe perhaps dynamically set the colorcolumn with it maybe more outstanding:
e.g if &wrap && !&tw | exe 'setl colorcolumn=' .. (!get(w:, 'wrapwidth', 0) ? '' : (get(w:, 'wrapwidth', 0) + 1)) | endif but on your event and when changed the wrapidth.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/1847/1753114194@github.com>

rickhowe

unread,
Oct 14, 2023, 12:11:05 AM10/14/23
to vim/vim, Subscribed

@rickhowe perhaps dynamically set the colorcolumn with it maybe more outstanding: e.g if &wrap && !&tw | exe 'setl colorcolumn=' .. (!get(w:, 'wrapwidth', 0) ? '' : (get(w:, 'wrapwidth', 0) + 1)) | endif but on your event and when changed the wrapidth.

I added a b:wrapwidth_hl or g:wrapwidth_hl option on 1.1. You can specify a highlight to make virtual spaces visible.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/1847/1762563284@github.com>

Shane-XB-Qian

unread,
Oct 14, 2023, 4:10:37 AM10/14/23
to vim/vim, Subscribed

@rickhowe i may prefer colorcolumn, but ok if you like that alternative line hl

image

but looks it has some issue when reset wrap back
// above case was wrap 78 on your readme.md and line 13
// that wrapped word 'screen' was flaky flied to somewhere.. 😄


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/1847/1762709010@github.com>

Shane-XB-Qian

unread,
Oct 14, 2023, 4:31:45 AM10/14/23
to vim/vim, Subscribed

it seems you did not trim these spaces ahead wrapped words when reset wrap/linebreak etc?
// anyway, looks this a useful plugin, specially if to view, take your time, i may check later.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/1847/1762740406@github.com>

rickhowe

unread,
Oct 14, 2023, 5:54:18 AM10/14/23
to vim/vim, Subscribed

it seems you did not trim these spaces ahead wrapped words when reset wrap/linebreak etc? // anyway, looks this a useful plugin, specially if to view, take your time, i may check later.

Let me ask you to post it on the issue page of the plugin.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/1847/1762781812@github.com>

Reply all
Reply to author
Forward
0 new messages