user419627
user419627

Reputation: 13

Vim line numbers on display lines

it is common knowledge the :set number will display the line numbers in vim. However, I have come an issue with this. When I use :set linebreak and reach a new line a number is not displayed with that newline. As I understand it these are referred to as display lines.

tl;dr How do I add line number to display lines?

Upvotes: 1

Views: 2683

Answers (3)

Ingo Karkat
Ingo Karkat

Reputation: 172758

If you want Vim to show display lines, not the actual, physical lines, that's not possible. It also doesn't make sense, since no movement command except gj / gk works on display lines, and you cannot use them in :[range].

Upvotes: 2

sehe
sehe

Reputation: 393829

This is not a feature of vim. If you want wrapped/broken lines to actually be new lines, why don't you actually make them new lines?

  • gqq reformats the current paragraph using the textwidth settting

To get automatic formatting going:

  • set fo=tcrwa textwidth=80

Now, whenever you're type your text will wrap around. On auto-wrap, a trailing space is left on the previous line indicating it isn't the end of a paragraph yet.

See vimdoc for 'fo-table'

Upvotes: 8

romainl
romainl

Reputation: 196876

There's no command :linebreak. Do you mean :set linebreak?

The line numbers displayed by Vim correspond to real lines in the file, not "display lines". If you hit <Enter> a real new line is created and Vim correctly shows its number.

Or you have :set wrap? In this case, wrapped lines are just a presentation trick: because it's still one real line it doesn't make any sense to display line numbers for non-existing lines. Anyway, even with :set wrap, hitting <Enter> still creates a real new line. So I'm not sure what exactly is your problem, here.

Upvotes: 2

Related Questions