• Ephera@lemmy.ml
    link
    fedilink
    arrow-up
    69
    ·
    2 months ago

    Recently had to edit the hosts-file on a remote host, and I don’t know if using two proxy jumps to SSH into it broke it, but it just wouldn’t let me select text with the mouse.
    I had to duplicate seven lines and edit the IP addresses, and without being able to copy-paste, I already saw myself manually typing it out.

    Then I remembered that in Vim, you can do d5↓ to delete 5 lines. Surely that would also work with copying/yanking. And yep, a y7↓ and a paste later and I had duplicated the lines.

    Then use the multi-line cursor like I routinely do for changing all 7 IP addresses…
    …and now I feel like I’ve crossed the line where people will think I’m just a wizard.

        • SpaceNoodle@lemmy.world
          link
          fedilink
          arrow-up
          7
          ·
          2 months ago

          That’s cool, and I can’t wait for it to gain widespread adoption, but nano is already more commonly installed by default.

        • fl42v@lemmy.ml
          link
          fedilink
          arrow-up
          2
          ·
          2 months ago

          “Sane” keybindings are questionable given Ctrl’s location (painful to press with both pinky and thumb fingers). It’s standard, I’ll give it that, but those in helix or vim are mostly (I’m looking at you, navigation between splits) much saner all things considered

      • Ephera@lemmy.ml
        link
        fedilink
        arrow-up
        3
        ·
        2 months ago

        Doesn’t that just cut one line at a time? Or is this Emacs-like, where it buffers the lines?

        That host doesn’t have internet access, though, so installing a different editor wasn’t really an option to begin with…

        • clb92@feddit.dk
          link
          fedilink
          English
          arrow-up
          2
          ·
          edit-2
          2 months ago

          Doesn’t that just cut one line at a time?

          Move the cursor to the start of what you want to cut, press ALT+A, then move the cursor with arrow keys (you’ll see text be highlighted from where the cursor was to where you move your cursor), then once you’ve moved the cursor to where you want, press CTRL+K to cut.

    • Coolcoder360@lemmy.world
      link
      fedilink
      arrow-up
      9
      ·
      2 months ago

      Just switch to visual mode and select the text and yank it.

      Press v where you want to start the selection from (switches to visual mode), hjkl (or arrow keys) to move the cursor to the end, then you can yank it from there. It’ll highlight what you’re selecting just like you’re using your mouse, but you’re using the keyboard.

      If you want to get really fancy there are 3 different kinds of visual mode, but lower case is the most often one that I use because it’s char by char, V is line by line, Ctrl+v is “block” (you can select chunks across several lines omitting things at the beginning or end of lines).

      Ctrl+V to do the block mode is nice if you need to edit the same part of several lines that all line up vertically, you just Ctrl+v, jk to select the lines, then I (shift+i) to insert on all those lines (if you’re in vim you can delete things in insert mode also, if you’re in vi you’ll need to delete first then insert)

      • Ephera@lemmy.ml
        link
        fedilink
        arrow-up
        3
        ·
        2 months ago

        Yeah, when I then used Visual Block mode to do the multi-line cursor, I realized I probably could’ve selected+yanked it that way, too.

        But that is some good info nonetheless. I wasn’t actually aware of the different Visual modes…

        • dQw4w9WgXcQ@lemm.ee
          link
          fedilink
          arrow-up
          3
          ·
          2 months ago

          I might be in a minority of this, but using numbers that way breaks my flow for 2 reasons: Firstly, any number of lines greater than around 3 or 4 means I have to stop and manually count. Not that counting to 6 takes a long time, but it does use some mental capacity while I want my mind focused on the actual code. Secondly, I don’t have touch typing in my fingers for the number line on my keyboard. If I need to type a number, I either have to look down at my keyboard, or move my hand over to the numpad. In both cases it would be quicker for me to Vjjjjjy.

          • fl42v@lemmy.ml
            link
            fedilink
            arrow-up
            2
            ·
            2 months ago

            manually count

            That’s why rnu (i.e. relative numbering) is mentioned, tho

    • nickwitha_k (he/him)@lemmy.sdf.org
      link
      fedilink
      arrow-up
      5
      ·
      2 months ago

      I’ve been using vim as my primary text editor and IDE for near a decade. I forgot that this was a thing so, I’ve been using visual mode like a peasant.

    • leisesprecher@feddit.org
      link
      fedilink
      arrow-up
      3
      ·
      2 months ago

      The real question is why you’re torturing yourself by manually fixing that stuff? Don’t you terraform your Ansibles?

      • Ephera@lemmy.ml
        link
        fedilink
        arrow-up
        2
        ·
        2 months ago

        That is a very good question. It all started as a dainty test setup, and I guess, we had lost the routine of always scripting hardware setups, because our previous project hadn’t required it.

        Obviously, the second-best time to start doing it is now, but I’d need to properly learn one of these first to be able to lead the way on that.
        Which collides with me not really wanting to use any of the ones I’ve experienced so far (Ansible, Puppet) in my freetime. 🫠

        • leisesprecher@feddit.org
          link
          fedilink
          arrow-up
          2
          ·
          2 months ago

          Ansible is actually pretty nice, if you get the hang of it. Not perfect, but better than triple tunnel ssh.

          You could simply automate step by step, each time you change something, you add that to the playbook and over time you should end up with a good setup.

          Flakey dev setups are productivity killers.

    • Rhaedas@fedia.io
      link
      fedilink
      arrow-up
      68
      ·
      2 months ago

      Steve Rogers: Big man in a suit of armour. Take that off, what are you?

      Tony Stark: Genius, billionaire, playboy, philanthropist.

      Tony was being snarky, but he’s not wrong about the suit being just an extension. Yes, it’s important to his abilities, otherwise he wouldn’t have needed it from the beginning in the cave. But it’s also not a crutch, as Ironman 3 showed and taught him, and he’s trying to show Peter that it begins with the person.

      Also keep in mind what he said to Peter in this same scene - when Peter said he just wanted to be like Tony, Tony comes back and says yeah, and I wanted you to be better. Tony knows that Peter truly doesn’t need the suit because he is that powerful, it’s just once again an extension that enhances those abilities, and if Peter thought it was the suit that made him special he wouldn’t grow.

    • Couldbealeotard@lemmy.world
      link
      fedilink
      English
      arrow-up
      34
      ·
      2 months ago

      Stark made the suit with no help. He doesn’t need a specific suit because he has the skill to invent whatever he may need.

      At this point, Peter can’t make himself a suit like that, so if he is nothing without it, he can’t respect the power it brings. But he isn’t nothing without it, which is what Stark is trying to teach him: not to rely on power of others.

  • nickwitha_k (he/him)@lemmy.sdf.org
    link
    fedilink
    arrow-up
    25
    ·
    2 months ago

    One of the things that really, really annoys me when I get lazy and use a pre-bundled set of (neo)vim plugins is how every one of them uses mouse functionality. I only use the mouse to copy/paste from the terminal to system clipboard. I don’t want it hijacking him and entering visual mode.

    • electricprism@lemmy.ml
      link
      fedilink
      arrow-up
      5
      ·
      2 months ago

      does this suggest that copy/paste from the terminal is broken by design and we need find a better way?

      • fl42v@lemmy.ml
        link
        fedilink
        arrow-up
        4
        ·
        2 months ago

        Vim has a better way, it’s called :set clipboard=unnamedplus (alternatively, one can bind anything else to copy/paste to/from system cliboards). Not sure why would one use a mouse for this, honestly

        • smiletolerantly@awful.systems
          link
          fedilink
          arrow-up
          2
          ·
          2 months ago

          I think if you want to copy a specific selection to a mouse-based, different program then it makes sense to use the mouse for precision selection.

      • Midnitte@beehaw.org
        link
        fedilink
        English
        arrow-up
        3
        ·
        2 months ago

        Might I suggest a common set of keybinds… maybe C for copy, and v for vaste… maybe use ctrl as well?

        • nickwitha_k (he/him)@lemmy.sdf.org
          link
          fedilink
          arrow-up
          6
          ·
          2 months ago

          Ctrl is already used my a large number of commands in POSIX shells. This is one of the places that I really like Apple’s solution (despite really not liking most of what they do). Super/GUI/Command + c/v is a great improvement in the terminal.

      • nickwitha_k (he/him)@lemmy.sdf.org
        link
        fedilink
        arrow-up
        2
        ·
        2 months ago

        You know, if I can use vim bindings and regex, I might try it out. I tend to try to keep my neovim plugins fairly lightweight when I config myself. Not being electron is a big plus.

        • JoYo 🇺🇸@lemmy.ml
          link
          fedilink
          English
          arrow-up
          4
          ·
          edit-2
          2 months ago

          yah helix has vim motions.

          their search mode and select is a bit different but once you do the tutorial it makes complete sense why youd want to scope your regex replace.

        • fl42v@lemmy.ml
          link
          fedilink
          arrow-up
          2
          ·
          2 months ago

          What stopped me personally was reading they use a different order of operations, so to say. Where vim goes action + range, helix goes (or at least used to go) range + action (like replacing ci" by i"c). Mb that makes more sense for them, but I’m too lazy to re-learn that for no particular reason

  • OpenStars@piefed.social
    link
    fedilink
    English
    arrow-up
    15
    ·
    2 months ago

    Okay but… obligatory “gVim offers the best of both worlds by offering use of a mouse if you want it”. There are also native ports for Mac OSX and Windows, etc.

    Vim, in contrast, is a command-line program, suited for e.g. working with a text file on a remote server that may not even be running an X-windows interface, or maybe the user simply did not bother to connect to it:-).

    Okay, we may now proceed with the humorous jesting:-).

    • azertyfun@sh.itjust.works
      link
      fedilink
      arrow-up
      7
      ·
      2 months ago

      Or just :set mouse=a if your terminal emulator was updated in the past decade. gVim has nothing to offer anymore, except that it bundles its own weird terminal emulator that doesn’t inherit any of the fonts, themes, settings or shortcuts of one’s default terminal. Blegh.

      Also if you’re not going to leverage Vim’s main feature and just want to click around on stuff, just install VSCod(e|ium), which is genuinely amazingly good.

      • OpenStars@piefed.social
        link
        fedilink
        arrow-up
        3
        ·
        2 months ago

        Absolutely. Plus the keyboard shortcuts are just outstanding - e.g. shift-M takes you to the middle of the screen - and you can even programmatically do things like make changes to every other line within the range 100-1000 but nowhere else, and even then restrict the changes to only those matching a pattern.

        And it is installed on most every machine in the world - even Windows is putting bash onto things these days (I forget if that is still optional, admittedly I haven’t touched Windows in nearly a decade:-P) - and has been since virtually the dawn of computing, certainly long before the modern age. :-D I’ve used ssh on a fucking blackberry and edited files with vim before smartphones existed!

        It is, however, notably hard to learn to use, I grant that:-).

  • Fonzie!@ttrpg.network
    link
    fedilink
    arrow-up
    10
    ·
    2 months ago

    Why are you using Vim for this? Vim actually allows you to change the cursor position and select text with the mouse if your terminal supports it.

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

      And if you enable the mouse while line numbers are set to be displayed, you can highlight multiple lines without needing to include the line numbers when you paste it later.

  • Evil_Shrubbery@lemm.ee
    link
    fedilink
    arrow-up
    9
    ·
    2 months ago

    Imagine using you mouser to click on all the things, like a pleb.

    Mice are for fps.

    /s
    (well, only like 62% sarcasm tbh)

  • riodoro1@lemmy.world
    link
    fedilink
    arrow-up
    4
    ·
    2 months ago

    Shit, the touchpad is right there. They even cut a hole for it in the case. I think im gonna use it.