0

A common operation for me is V <movement commands> d k o ESC to delete a bunch of lines and add a newline. Is there a quicker vim way to do this?

4
  • 3
    V <movement> c ESC ?
    – Rich
    Feb 18, 2021 at 16:31
  • 3
    Also ko is (almost) always the same as O.
    – Matt
    Feb 18, 2021 at 16:33
  • 1
    Welcome to Vi and Vim!
    – filbranden
    Feb 18, 2021 at 17:02
  • 1
    I typically do the same: I think it's a fine pattern. Perhaps there's a way to achieve it with fewer keystrokes, but it probably has more "mental overhead" (you need to think more about what you're doing) so not sure if it will be faster/more convenient. A smarter way to do something in Vim isn't necessarily a better way to do it! Feb 20, 2021 at 0:22

2 Answers 2

1

You could get it simply with:

<num>cc

From vim's :help cc

["x]cc          Delete [count] lines [into register x] and start
            insert |linewise|.  If 'autoindent' is on, preserve
            the indent of the first line.

1
0

0c<num>j

0: go to the line start

c: prepare to replace

<num>j: move <num> lines down

1
  • @guntbert doubtful, C doesn’t take a motion (it’s the same as c$
    – D. Ben Knoble
    Feb 19, 2021 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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