Rolf
Rolf

Reputation: 1199

Is there a way to show line numbers at end of the line in Vim

I am using

set relativenumber
set number

which let's me move easily around. However, it is often hard to know the exact the line number of the object where I would like to jump to because I first need to look to the left. I feel it would be easier if I could see the line numbers also on the right hand side right because my eyes have less space to follow (maybe?). I think the ideal setting would be to show the relative/absolute line number where the $ appears when whitespace characters are shown and to the left/right of the buffer. I.e.

  1 Random text.$1                                                                 1  
159 This is the line where the cursor is.$159                                    159
  1 Some random text.$1                                                            1
  2 More random text. Another sentence. Maybe a third one? And so on.$2            2
  3 Another line which might be quite long and my eyes focus somewhere here.$3     3
  4 More random text containing more text and more words and stuff.$4              4

(In this example, I would like to do 3k but I may type 2k or 4k because I did not follow the correct line to the left.)

Is it possible to achieve this somehow? Any suggestion on how to change my workflow are welcome, too.

Note: Using cursorline does not help as I do not seek the number of the current line.

Upvotes: 2

Views: 380

Answers (2)

Ingo Karkat
Ingo Karkat

Reputation: 172500

No, that's not possible, unless you modify Vim's source code in a non-trivial way, or work around with kludges like a vertically split small scratch buffer at the side that is updated via autocmds.

Do you have :set cursorline? That helps (me) a lot to follow the current line, even with large window widths. Reducing those might help, too, though you have to deal with wrapping / scrolling of long lines then.

Upvotes: 3

Kent
Kent

Reputation: 195029

No, there is no built-in support to your requirement. also I don't think this is easy to be done by plugin.

Maybe you could consider to change your habit/workflow. E.g. enable the cursorline option, to highlight your "current" line, it may let you easier to identify which line are you on right now.

To move cursor, if you don't want to count lines, you may want to try the EasyMotion plugin. It is very handy plugin. However it won't replace the hjkl ... motions.

Upvotes: 4

Related Questions