I’d like actual examples instead of “I work faster”, something like “I can move straight to the middle of the file with 7mv” or “I can keep 4 different text snippets in memory and paste each with a number+pt, like 2pt”, things that you actually use somewhat frequently instead of what you can do, but probably only did once.

  • ExperimentalGuy@programming.dev
    link
    fedilink
    arrow-up
    8
    ·
    5 months ago

    I use vim bindings in vscode, but I’m trying to switch to neovim.

    It’s hard to talk about efficiencies without use cases but here’s some that I like:

    • Compared to using mouse, text selection is just much easier in vim. Instead of accidentally highlighting an extra space and clicking somewhere on accident which gets rid of my selection, vim lets me go directly to the end of the word and be precise about where I’m selecting.
    • I remember before I used vim, I would count the number of times I hit the backspace or delete when I had heavily nested parentheses. With vim I just type the exact number I want, and if I were to undo that operation I also know exactly what was changed, whereas when counting there’s always the possibility of miscounting or pressing delete without counting.
    • I don’t have to scroll. I can jump 100 lines in less than a second. Instead of searching through long files to find where I left off, I just generally remember what line number I was at, then I can simply just jump back.
    • Forces me to type better. Before vim I had really shitty typing form(I don’t know what it’s actually called) but switching to vim shone a light on exactly how I was typing wrong, and now I type faster.
    • Using the % operator you can jump between brackets or parentheses. This comes in handy especially when you want to highlight the inside of a function call, or just jump to the end of a pair of brackets
    • FizzyOrange@programming.dev
      link
      fedilink
      arrow-up
      2
      arrow-down
      2
      ·
      5 months ago
      1. Ctrl-left/right jump to the beginning/end of words
      2. No exactly sure what you mean here.
      3. Page up/down let you scroll up/down quickly. Ctrl-P :123 lets you jump to a specific line, but I generally use editing history (alt-left) instead.
      4. I can type perfectly well…
      5. Ctrl-{ or } does this I think.

      Do you have any more compelling examples?

      • abruptly8951@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        5 months ago

        Ooh fun, these all take 2-3 key presses

        • Delete the contents inside a function delimiter by {
        • Delete the next nine words
        • Delete the contents inside long text quotes

        And these more/less key presses

        • Start a regex search with a single button
        • Perform the same edit 100 times in a jagged files (good luck not f’ing up your multi cursor)

        But it misses the point, of course every editor can do just about anything, but there is a lot more mouse involved and learning it is more difficult because the keybinds aren’t combinatorial

        • FizzyOrange@programming.dev
          link
          fedilink
          arrow-up
          1
          arrow-down
          1
          ·
          5 months ago
          1. Ctrl-shift-}
          2. How often do you want to delete exactly 9 words? It’s much easier if this is interactive.
          3. Not a common task IMO.
          4. Ctrl-F and click a button. This is rare enough that a button click is fine.
          5. Not sure what you mean by “jagger files” but I find multiple cursors are a lot easier to get right than e.g. regex replace because they give you instant feedback. Vim sequences are more like “oh you got it wrong, better start from scratch”.
          • abruptly8951@lemmy.world
            link
            fedilink
            arrow-up
            1
            ·
            edit-2
            5 months ago

            1 is just going to highlight right?

            2, how about 6 words, 10 words, 100 words

            3, 4 I use all the time

            5 if your edit locations don’t line up so that you can alt drag a single column, this is what I mean by jagged. I would use a combination of find and repeat action.

            Start from scratch - skill issue :p

            • FizzyOrange@programming.dev
              link
              fedilink
              arrow-up
              1
              ·
              5 months ago

              how about 6 words, 10 words, 100 words

              Yes exactly my point. How often do you need to delete exactly 100 words? Do you count them? Obviously not - you probably guess and delete 50, and then 25 and then 20 etc.

      • Kornblumenratte@feddit.de
        link
        fedilink
        arrow-up
        1
        ·
        5 months ago

        Superficially, typing <Ctrl>+<left> seems to be the same as typing <Esc> <b>, but these are two completely different paradigms of using the editor.

        Vim does not use shortcuts or hotkeys to edit the text, it uses a language to communicate with the editor.

        For me, shortcuts and hotkeys are rote memorization, and I’m bad at rote memorization – compare your point “5. Ctrl-{ or } does this I think”. Do I need Ctrl-left, Super-left, Alt-left, Shift-left or Ctrl-Shift-left to jump back a word?

        The vim editing language is mostly consistent and logical. I did not need to memorize it, I could learn and understand it. But that’s just me.

        Far too much examples:

        Most commands are abbreviations – a for append, b for back, c for change, d for delete, e for end of word, f for forward, g for goto (and more), hjkl are special, i for insert, m for mark, n for next, o for open line, p for paste, q for reqord macro is a strange spelling, r for replace, s for substitute, t for to, u for undo, v for visual mode, w for word, x for extinguish, y for yank, z is just a prefix for arcane stuff. Capital letters are usually variants of their minuscle counterpart – like A for append at end of line.

        Commands take a repeat count, and a lot of commands take objects/movements, and these reuse the commands, like “delete inside backticks” => di`, “yank inside brackets” => yi{, “change up to third slash” => c3t/

        If you are fluent in vim, you won’t type shortcuts while editing, you will talk to your editor.

        As for more compelling examples:

        “I’d like to change the next 2 sentences” translates to )c2)

        “Please format this paragraph.” translates to gqap

        “Swap these two characters.” translates to xp

        And I did not touch ex mode, vimscript and plugins yet.