0

This is relativenumber. It shows the line numbers, relative to your cursor:

1 one line before your cursor
0 your cursor is here
1 first line after
2 second line
3 third line
4 and so on

It's super useful for quickly editing a number of lines. But is it possible to have the same thing, except for characters in a line? Something like this:

8    3  0 2      10   16    22 25  X  X        X  X     X      X       X       X      X
This is a pretty long line. It can be annoying to edit. EspeciallyIfThere'sALotOfTextAtOnce
        ^
 your cursor is here  

You can see that each word or longer string of characters has a relative character count number on top of it (I stopped using numbers and started using X's eventually, but you get the point).

So let's say I want to edit the string It can be annoying to It is annoying. I could do 25k to go to the word I want to edit, type 2cw to change two words and replace them with the string "is".

Considerations:

  • The numbers need to be spaced out because having them too close to each other would be confusing
  • Using characters instead of numbers (e.g X and Y instead of 100 and 105) might be a good idea

Is there any existing solution out there for accomplishing this? I'd like to give it a try.


Edit: An even better idea might be to display word numbers instead of character numbers. Like this:

2    1  0 1      2    3     4  5   6  7        8  9          
This is a pretty long line. It can be annoying to edit. 
        ^
 your cursor is here  

If the number 5 is on top of the "can", then I can just type 5w to go to the word "can".

8
  • 1
    I've never seen anything that numbers columns but there are a number of plugins that make it easy to navigate to various places on a line (or page) using "hints" (e.g. 1-3 letter tags). easymotion is probably the most popular of these.
    – B Layer
    Sep 14 at 12:34
  • 2
    BTW, in native Vim you could just do fc to get to can. Or 2fl to get to line. And so on. Combined with ; and , to go forward/backward by one occurrence and you can move about pretty adeptly.
    – B Layer
    Sep 14 at 12:43
  • Yes, I'm aware, but that's not reliable. If there's a "c" character somewhere in between there, then you will go to the first "c" you encounter, not the one you want to go to. Though, I didn't know about ; and ,, so maybe I should give it another shot (though I would still prefer being able to get to where I want to go with one command, and not have to pay attention to whether I've gone too far or not). I've been typing /can, but I'm looking for something faster, where I don't have to worry about escaping regex Sep 14 at 12:45
  • 1
    Yeah, I'd never use /can but I use f, F, t, T, ;, , (along with the other basics like w and b) pretty adroitly after some practice...to the point that I don't feel the need for something like what you describe or EasyMotion.
    – B Layer
    Sep 14 at 12:50
  • 1
    Personally I’ve come to believe that searching for target fragments is the fastest way to get places.
    – D. Ben Knoble
    Sep 14 at 17:31
0

Plugin suggestions from the comments:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.