1

I personally prefer nano over vim because vim just works so much differently than a standard text editor...it can really be stressful if you don't understand how to use it efficiently.

However, today i was wondering if vim made it possible to do this: you have numbering enabled, and you are in the default/normal mode. You see a line that you want to get rid of , yet replace with different text. Is there a command to start you in insert mode at that particular line automatically? Would you be able to erase that line with 123dd before that? Just to be clear, what i'm asking is if you can enter the line number then hit some key and wind up in insert mode right there. I know that you could press "123G Enter" then i, but i'm wondering if there's a way to enter the line number, then hit one key on your keyboard to get there and switch modes, i know that hitting 123i does not work because i just tried it...

2
  • 1
    There's not (out of the box) a "Go here and start typing text" in one keystroke, because generally vim works in what I think of as short "sentences". ci" for example is "Change inside double-quotes", or 22G is "Go to line 22". One sentence would do one thing, and here you are asking to do to things (to wit: move the cursor to a line, and change the contents of that line). One of your examples would be "delete the next 123 lines" for 123dd. 123i simply puts you into insert mode because "put me into insert mode 123 times" would be functionally be the same as just once.
    – DopeGhoti
    Commented Nov 2, 2022 at 3:13
  • Well good thing i didn't hit 123dd then! Commented Nov 2, 2022 at 17:29

1 Answer 1

1

For line n, nGC. G to Go to the start of a line by number, and C to Change the contents of the entire line starting at the cursor (which you have just placed at the start of the chosen line), which puts you into Insert mode.

1
  • Wow! That did exactly what i described in the question...the reason i haven't entirely given up on vim is that it's such an enormous program, just cuz i don't know how to do something doesn't mean it can't be done... Commented Nov 2, 2022 at 17:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .