[vim/vim] Setting 'showbreak' affects the reported virtual column number in the status line. (Issue #14759)

14 views
Skip to first unread message

lkintact

unread,
May 12, 2024, 11:36:01 AM5/12/24
to vim/vim, Subscribed

Steps to reproduce

  1. Run gvim.exe --clean.
  2. Execute :set showbreak=>.
  3. Execute :set laststatus=2 to enable the status line.
  4. Execute :set statusline=%v.
  5. Type 1000ia<Esc> to put 1000 letters "a" in the buffer. Note that the status line reports "1012".

Expected behaviour

The status line should report "1000".

Version of Vim

9.1.296.

Environment

OS: Windows 10 Home.
Terminal: GUI.

Logs and stack traces

No response


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/14759@github.com>

Gary Johnson

unread,
May 12, 2024, 12:23:35 PM5/12/24
to reply+ACY5DGAIS6JBRGL3ZF...@reply.github.com, vim...@googlegroups.com
On 2024-05-12, lkintact wrote:
> Steps to reproduce
>
> 1. Run gvim.exe --clean.
> 2. Execute :set showbreak=>.
> 3. Execute :set laststatus=2 to enable the status line.
> 4. Execute :set statusline=%v.
> 5. Type 1000ia<Esc> to put 1000 letters "a" in the buffer. Note that the
> status line reports "1012".
>
> Expected behaviour
>
> The status line should report "1000".
>
> Version of Vim
>
> 9.1.296.
>
> Environment
>
> OS: Windows 10 Home.
> Terminal: GUI.

The number 1012 is correct. The statement closest to a definition
of "virtual column" I could find in Vim's help is in ":help
wincol()":

The result is a Number, which is the virtual column of the
cursor in the window. This is counting screen cells from the
left side of the window. The leftmost column is one.

A 1000-character line displayed in an 80-column window will wrap 12
times. Each time it wraps, Vim inserts the single-character
'showbreak' string, increasing the number of virtual columns
occupied by the text by one each time.

This is most easily seen at the end of the first screen line, column
80. With the cursor at column 80, the status line shows "80". Type
l to move the cursor one character position to the right. The
status line now shows "82". The cursor has moved to character
position 81 but to virtual column 82 because that count includes the
">" at the left edge of the screen.

HTH,
Gary

vim-dev ML

unread,
May 12, 2024, 12:24:00 PM5/12/24
to vim/vim, vim-dev ML, Your activity

On 2024-05-12, lkintact wrote:
> Steps to reproduce
>
> 1. Run gvim.exe --clean.
> 2. Execute :set showbreak=>.
> 3. Execute :set laststatus=2 to enable the status line.
> 4. Execute :set statusline=%v.
> 5. Type 1000ia<Esc> to put 1000 letters "a" in the buffer. Note that the

> status line reports "1012".
>
> Expected behaviour
>
> The status line should report "1000".
>
> Version of Vim
>
> 9.1.296.
>
> Environment
>
> OS: Windows 10 Home.
> Terminal: GUI.

The number 1012 is correct. The statement closest to a definition
of "virtual column" I could find in Vim's help is in ":help
wincol()":

The result is a Number, which is the virtual column of the
cursor in the window. This is counting screen cells from the
left side of the window. The leftmost column is one.

A 1000-character line displayed in an 80-column window will wrap 12
times. Each time it wraps, Vim inserts the single-character
'showbreak' string, increasing the number of virtual columns
occupied by the text by one each time.

This is most easily seen at the end of the first screen line, column
80. With the cursor at column 80, the status line shows "80". Type
l to move the cursor one character position to the right. The
status line now shows "82". The cursor has moved to character
position 81 but to virtual column 82 because that count includes the
">" at the left edge of the screen.

HTH,
Gary


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/14759/2106305967@github.com>

Christian Brabandt

unread,
May 12, 2024, 1:01:49 PM5/12/24
to vim/vim, vim-dev ML, Comment

Closed #14759 as not planned.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/issue/14759/issue_event/12779035460@github.com>

Christian Brabandt

unread,
May 12, 2024, 1:01:50 PM5/12/24
to vim/vim, vim-dev ML, Comment

correct, or saying it differently, the virtcol() gives the column where it appears on the screen. So if you disable the showbreak setting and type 1012a characters, it would end at exactly the same position. So it is on which column a letter appears on the screen, when counting left to right, top to bottom, including any fancy text decorations, like tab, linebreak, breakindent, showbreak and others.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/issues/14759/2106315144@github.com>

lkintact

unread,
May 12, 2024, 1:25:37 PM5/12/24
to vim/vim, vim-dev ML, Comment

Gary, Christian, thank you, guys.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/issues/14759/2106320452@github.com>

Reply all
Reply to author
Forward
0 new messages