0

I'm a new Vim user (using the Vim extension in VSCode), and while it's faster at some operations, I'm having a lot of trouble finding an easy way to cut text (copy and delete it), then paste it at another section. Currently, with my understanding, what I'm having to do is

  1. Go from insert -> normal - > visual
  2. Highlight what I want to yank then press y
  3. Re-highlight selection and delete
  4. Navigate to where I want to paste the entry I cut (usually end up with extra spacing or characters from the yank, then need to go back into insert to clean it up)

This is simply much faster for me without Vim—what am I missing?

1
  • 1
    Even if you don't want to use the real vim and just an emulation you should still run vimtutor and learn what it says it is the very basics that you need to know about vim. For your use case you'll see lessons 1.3, 2.1 and 2.2 which will teach you about the commands d and x
    – statox
    Mar 10 at 8:27
3

I think you're missing some fundamentals from vim (and I don't mean this in a "one true way to Vim" sense, although my first point does come close to that). As statox mentions in the comments, running vimtutor might be a good starting point.

Here's a faster process:

  1. You're already in normal mode. It's the default (hence "normal"). So no switching required.
  2. Just d the thing you want to "cut." Often, a text-object or motion can save you visual mode (so, learn about daw, dap, dib, etc., at :help text-objects and d/foo<CR>, d5j, etc., at :help {motion}/:help motion.txt).
  • If the thing to "cut" is too complex, sure, visual mode will help. But press d or x to delete instead of yanking then deleting
  • If you find yourself re-selecting the same visual-area, learn about :help gv
  1. Since you deleted the text, it's in a register. (Almost always ", which is the default, and often one or two other places; you can control where if you learn about :help registers—e.g., "bdap deletes a paragraph into register b.) This means that p/P/:put[!] will paste the thing you just deleted (and they take registers too!).

All in all, cut-n-paste is still about 3 steps: delete the thing, move to where you want to put it, and put it. (And if moving is slow, consider learning some more navigation commands. Search is often the fastest!)


If you're cleaning up extra spaces from insert-mode with backspace, try x/X/d in normal mode (again).

1
  • 1
    +1 for “You’re already in normal mode” alone. (Although the rest of the answer is great, too.)
    – Rich
    Mar 10 at 22:22

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.