653
You don't need the mouse (lemmy.blahaj.zone)
submitted 1 year ago by Soluna to c/programmerhumor@lemmy.ml
top 50 comments
sorted by: hot top controversial new old
[-] Ephera@lemmy.ml 69 points 1 year 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 34 points 1 year ago

Ctrl-K and Ctrl-U in nano, a sane editor that does not hate you

[-] eager_eagle@lemmy.world 29 points 1 year ago

Ctrl-X Ctrl-V in micro, if you appreciate a sane editor with sane keybindings.

[-] SpaceNoodle@lemmy.world 7 points 1 year ago

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

[-] Blisterexe@lemmy.zip 5 points 1 year ago

How does micro compare to nano?

[-] SpaceNoodle@lemmy.world 32 points 1 year ago
[-] eager_eagle@lemmy.world 7 points 1 year ago
[-] eager_eagle@lemmy.world 5 points 1 year ago* (last edited 1 year ago)

better ootb experience with syntax highlighting, sane keybindings, plugin system, and other little things nano lacks.

[-] SpaceNoodle@lemmy.world 4 points 1 year ago* (last edited 1 year ago)

Nano has had syntax highlighting for quite a while.

Its keybindings also make sense if your brain is still stuck in the '90s. If not, they're literally printed at the bottom of the terminal.

If I need plugins, I'm not gonna be fucking around with a terminal text editor.

What are these "other little things?" Certainly not "probably already installed on your system."

load more comments (2 replies)
[-] fl42v@lemmy.ml 2 points 1 year 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

[-] eager_eagle@lemmy.world 2 points 1 year ago

or maps your caps to Ctrl, like vim users map it to esc

load more comments (2 replies)
[-] mosiacmango@lemm.ee 19 points 1 year ago

Vim doesn't hate you. It loves who you could be.

[-] SpaceNoodle@lemmy.world 7 points 1 year ago

I wish I could :q! you

[-] nickwitha_k@lemmy.sdf.org 5 points 1 year ago

How do I do regex or connect to an LSP with nano?

[-] SpaceNoodle@lemmy.world 8 points 1 year ago

That's the neat part: you don't.

[-] nickwitha_k@lemmy.sdf.org 3 points 1 year ago

Fair enough. Those are things that I like to be able to use, however. Which makes nano/pico/micro a non-starter for me. Different strokes for different folks.

[-] SpaceNoodle@lemmy.world 3 points 1 year ago

Well, they're not necessary for 99.999% of what you need a quick CLI text editor for.

load more comments (1 replies)
[-] Ephera@lemmy.ml 3 points 1 year 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...

[-] SpaceNoodle@lemmy.world 6 points 1 year ago

If the host doesn't already have nano, you fucked up super early

But yeah, it buffers the lines.

load more comments (1 replies)
[-] Coolcoder360@lemmy.world 9 points 1 year 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)

[-] jaybone@lemmy.world 6 points 1 year ago

Had not heard of block mode. I need to try this.

[-] Ephera@lemmy.ml 3 points 1 year 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...

load more comments (3 replies)
[-] nickwitha_k@lemmy.sdf.org 5 points 1 year 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 3 points 1 year ago

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

[-] JoYo@lemmy.ml 2 points 1 year ago

lol @drudgesentinel@fedi.seriousbusiness.international

load more comments (2 replies)
[-] nickwitha_k@lemmy.sdf.org 25 points 1 year 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 5 points 1 year ago

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

[-] nickwitha_k@lemmy.sdf.org 6 points 1 year ago

I like your thinking. Give me Firefox with a TUI and POSIX shell i/o redirection support.

[-] fl42v@lemmy.ml 4 points 1 year 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

load more comments (1 replies)
[-] Midnitte@beehaw.org 3 points 1 year ago

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

[-] nickwitha_k@lemmy.sdf.org 6 points 1 year 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.

load more comments (4 replies)
[-] OpenStars@piefed.social 15 points 1 year 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 7 points 1 year 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 3 points 1 year 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:-).

[-] JoYo@lemmy.ml 11 points 1 year ago

ive been doing this for long enough to know you can use any text editor without a mouse.

[-] lord_ryvan@ttrpg.network 10 points 1 year 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 2 points 1 year 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 9 points 1 year 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 4 points 1 year ago

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

[-] stupidcasey@lemmy.world 3 points 1 year ago

We’ll Skibidi Dibidi At’el Do.

load more comments
view more: next ›
this post was submitted on 26 Oct 2024
653 points (100.0% liked)

Programmer Humor

38973 readers
224 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 6 years ago
MODERATORS