• [object Object]@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    13 hours ago

    I hope that you use the motion commands at least, because that’s the whole point of the separate modes. If not, you should look them up and add some of them to your workflow little by little.

    The most basic ones are wand b to go a word forward or back; 0 and $ to go to the start or end of the line, or g0 and g$ for the visual line. f to jump to a particular letter forward. { and } to go to the start/end of the paragraph.

    V is useful for selecting whole lines. ctrl-v for block selection (or ctrl-q, depending on your setup).

    % can jump or select to the matching parenthesis or brace. With matchit installed, it also jumps to matching keywords like end or HTML tags.

    gc comments out the selection (or uncomments it). Works with motions too, like gcc.

    For pasting, you should use p in the normal mode. Also P pastes before the cursor. This is useful for moving text around by deleting it with something like daw, jumping elsewhere, and doing p.

    And of course, the regex replacement with :s// is very useful if you have more than a few lines that need approximately the same change.

    • sem@piefed.blahaj.zone
      link
      fedilink
      English
      arrow-up
      1
      ·
      12 hours ago

      This is all very advanced to me. I use Home and End to go forward and back in the line, but w and b sound good to m (just wish they made more intuitive sense), also p and P.

      I should print out a ref sheet.

      • [object Object]@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        11 hours ago

        Vim has a built-in tutorial on the motion commands and such. I don’t remember how it’s invoked, but probably something like :help tutorial. You’ll get an overview of the commands and see which ones might be useful to you right away. As I mentioned, I recommend getting the hang of them one or a few at a time, so they are incorporated in your toolbox.

        Speaking of help, it’s generally useful in Vim to use :help {something} when you want to recall how something works. It has consistent naming for the help pages for various functionality, e.g. :help :s shows the page about the :s command, and there are pages for every motion command, etc. — I don’t remember the prefixes as it’s been a while since I used Vim proper, but just :help should give you an index.

        Also, if you’re coding in Vim, there are ways to integrate documentation for your language, so that K would show help for the function or whatever under the cursor. Back in the day I’ve had PHP docs plugged into Vim, but it’s been a while, so idk how it’s done now. Iirc there are dumps of docs from the Dash app, which might be available as vimdocs.