this post was submitted on 25 Dec 2023
655 points (99.7% liked)

196

16508 readers
2264 users here now

Be sure to follow the rule before you head out.

Rule: You must post before you leave.

^other^ ^rules^

founded 1 year ago
MODERATORS
 

First time when you ssh into your Linux terminal and you gotta “sudo crontab -e” or something and it’s like “what editor do you want to use?” and nano sounds lame so you choose vim cause the sound is cool when you say it and then you have to wipe the whole comp and start over

top 50 comments
sorted by: hot top controversial new old
[–] [email protected] 49 points 10 months ago* (last edited 10 months ago) (6 children)

How do I exit Vim?

escape colon w q

One of life's great mysteries

escape colon w q

I'm pretty sure it's impossible

it is literally. the first result on google.

The best way is to change to another terminal and forcequit it from there

escape then Shift+Z twice also works. or shift+Z shift+Q to quit without saving.

Or hard restart your entire computer

Are you people allergic to search engines or someth--

Bill Joy made vi impossible to exit because he wanted the source to always be open

siiiiiiiiigh

Yes, I'm an old man yelling at cloud, but Vim and Neovim are fantastic text editors that really are worth the half hour you'll spend running through the tutorial to learn them, and the subsequent two weeks you'll spend installing plugins and configuring it exactly to your liking. It really does make writing software more efficient and really doesn't deserve the reputation it gets from "vim is hard to exit lmao" memes made by people who haven't bothered to change their $EDITOR to nano, had it launch automatically when they tried to write a commit message, and instantly decided it was just yet another piece of arcane 80s Unix bullshit

[–] [email protected] 22 points 10 months ago (1 children)

vi isn't a text editor as much as it's a text manipulation language.

It has a syntax, grammar, idioms, and, yes, a learning curve.

But once you learn it, it's as close to a brain-computer interface as I've experienced. You start thinking about edits as chainable operations and it literally becomes muscle memory -- if you ask someone experienced with vi how they just did a complex sequence of edits, chances are they'll have to stop and consciously walk through it because they literally didn't have to think about it the first time.

[–] [email protected] 5 points 10 months ago (1 children)

got any online course recommendations? my college recommended missing semester for the basics of the basics, but i know there are so many more and other vim workflows (easy motions etc)

although i should first start getting into touch typing

[–] [email protected] 2 points 10 months ago

In the terminal write ‘vimtutor’, that covers the basics.

[–] [email protected] 8 points 10 months ago

"All my homies hate :wq"

  • :x gang
[–] [email protected] 4 points 10 months ago

At first I did now understand it, why would you even use it??(vim / neovim) It would take ages to learn it all. Then got around to try it, and in a span of like a week, I couldnt go back to editing text with a mouse. I wasnt efficient at first, but damn was it fun. Just cruising around the codebase without touching the mouse (as much as i could.)

Yeah, it makes you more efficient if youve learnt it enough, but at the same time, it makes editing literal text way more enjoyable. You need to edit some boilerplate, and it actually becomes somewhat interesting like: 'Can I use a macro here', or 'How can i do it the most efficient way?’.

I think it also gives you a state of mind as well (for me it definitely shaped it.) You want to learn your tools, you want to understand what makes a good text editor (ex. LSP), or just perfecting your usabilitx of a terminal / shell.

At the same time, damn sometimes its a straight up curse that i learnt vim. I open any other text editor and i just curse the whole time: 'Where are my vim motions?!!?

P.S. Remapping Escape to Caps Lock made vim usability to a 10 for me.

[–] [email protected] 3 points 10 months ago (2 children)

First time using Linux and in a job setting isn’t the time to get Vim’d, so yeah I dipped. Don’t judge too hard pls!

[–] [email protected] 12 points 10 months ago (2 children)

I am a professional linux sysadmin, and I don't use Vim. There is honestly no task you will ever do that will actually require familiarity with Vim. You can get by with Nano just fine.

[–] [email protected] 3 points 10 months ago

vim feels nicer though :/

[–] [email protected] 3 points 10 months ago (1 children)

I use nano on my servers because the default configuration can be used by pretty much anyone, even if I had to explain it to someone over the phone. And hopefully you rarely if ever have to make sophisticated changes to files on servers that would benefit from vim's model.

If you do need to do consistent heavy-duty file editing on a server, rmate is really nice for that: https://github.com/aurora/rmate

But honestly both of these strategies are dated and I don't use either of them professionally. These days it's all immutable infrastructure: I use my local editor to make build scripts for immutable server images that there's no point in editing files on running instances because none of the changes will be persisted.

load more comments (1 replies)
[–] [email protected] 4 points 10 months ago* (last edited 10 months ago)

I actually learned while writing docs for work because it was boring as fuck otherwise. Now I'm one of those people. Give it a shot if you want to spice up (and dramatically slow down at first) some tedious work for a bit.

load more comments (2 replies)
[–] [email protected] 42 points 10 months ago (2 children)

Off-topic: never unplug this way, it’s bad for your cable and potentially dangerous.

[–] [email protected] 56 points 10 months ago (2 children)
[–] [email protected] 26 points 10 months ago (1 children)

It’s got ground so it’s certified safe!

[–] [email protected] 13 points 10 months ago (1 children)

You'll have about 6ft of ground afterwards.

[–] [email protected] 5 points 10 months ago (1 children)

That cord is two feet long at best.

[–] [email protected] 6 points 10 months ago

It's actually 40 ft long, it's just really big

[–] [email protected] 3 points 10 months ago

I wanted the rest of the song. I asked Bing to make it, sorry Copilot. I am not disappointed

You heard there was a secret chord That you could use to meet the Lord 'Cause you don't care about power safety, do ya? You plugged it in without a thought And then you saw a bright blue spark And from your lips you screamed a loud "Hallelujah!"

Hallelujah, Hallelujah Hallelujah, Hallelu-u-u-u-jah

Your room was dark, you smelled some smoke You realized you made a joke Of basic rules of electricity, didn't ya? You tried to find another plug But all you got was just a shrug And from your phone you heard a low "Hallelujah!"

Hallelujah, Hallelujah Hallelujah, Hallelu-u-u-u-jah

You called the landlord right away He said he'd come and fix the fray But he would charge you extra for the labor, yeah You felt a pang of guilt and shame You knew you only had yourself to blame And from your wallet you let out a sigh "Hallelujah!"

Hallelujah, Hallelujah Hallelujah, Hallelu-u-u-u-jah

[–] [email protected] 8 points 10 months ago

It's safer than losing your sanity to vim

[–] [email protected] 18 points 10 months ago (1 children)
[–] [email protected] 26 points 10 months ago* (last edited 10 months ago) (1 children)
[–] [email protected] 16 points 10 months ago (1 children)
[–] [email protected] 16 points 10 months ago

you have escaped

[–] [email protected] 17 points 10 months ago (4 children)

lawful good: alias vim=nano

chaotic evil: alias nano=vim

[–] [email protected] 14 points 10 months ago

If I typed vim and it opened nano I would start looking for people to kill

[–] [email protected] 7 points 10 months ago

Setting vim to alias to nano seems just about as chaotic evil as making the VS Code icon take you to notepad.

[–] [email protected] 6 points 10 months ago

I would detonate if someone chaotic evil’d me

[–] [email protected] 4 points 10 months ago

I dunno, those both seem pretty chaotic evil to me.

[–] [email protected] 15 points 10 months ago (3 children)

I develop only in vim, i find it way better that any modern gui.

[–] [email protected] 7 points 10 months ago (2 children)

VSCode with the VIM mode plugin is kind of the best of both worlds.

[–] [email protected] 6 points 10 months ago

I dislike the graphical interface. Console helps me to be more productive.

load more comments (1 replies)
load more comments (2 replies)
[–] [email protected] 15 points 10 months ago

Quitting Vim is called 'escaping' because it was designed to be a trap and you've escaped. Congratulations to everyone who has.

[–] [email protected] 13 points 10 months ago (3 children)

How to use Vim: 1- Don't use it. 2- Use Nano or Gedit lmao.

[–] [email protected] 10 points 10 months ago (1 children)

Until those are not available.

This is a pisspoor attitude to have, just fire up vimtutor and you will know how to use it in no time.

[–] [email protected] 7 points 10 months ago (3 children)

Unless you're a sysadmin who deals with very obscure systems, you'll always have access to nano, so why bother?

Vim elitists love to brag about how cool Vim is, but pretty much never properly elaborate. Why should I learn all those obscure commands to just edit some text? What's the point?

[–] [email protected] 7 points 10 months ago (1 children)

it feels smooth
the movement is very fast and precise
you don't need to move your hand for arrow keys so it's nice when you're lazy
i dont use vim anymore though, i use helix because it's purple

[–] [email protected] 3 points 10 months ago

Lol

Gotcha!

[–] [email protected] 3 points 10 months ago (4 children)

Even not being a vim wizard, editing code without vim keybindings feels... slow.

Yeah, I could grab the mouse, highlight everything between the arguments to a function and hit delete. Or I could just go to the open paren and just hit d%. I could grab the mouse, highlight the line and hit delete, or I could literally just type dd.

And trying to edit things in nano is positively masochistic.

load more comments (4 replies)
[–] [email protected] 3 points 10 months ago

I learned them and basically never use vim.

I use sed if i need to change things with a pattern, cat the file if i need to see the contents, use head or tail if its too much to fit on the screen.

If I am writing code, I use a code editor. Emacs and vim can do a lot, but they can also fuck off.

load more comments (2 replies)
[–] [email protected] 9 points 10 months ago

Who told you to add a job to your root crontab? Vim was just protecting you from yourself

[–] [email protected] 8 points 10 months ago (1 children)
[–] [email protected] 9 points 10 months ago (1 children)
[–] [email protected] 8 points 10 months ago
[–] [email protected] 6 points 10 months ago

[CTRL][ALT][PrtSc]-K-S-U-B

or [ESC] :q!

YMMV

[–] [email protected] 6 points 10 months ago* (last edited 10 months ago)

:q it's very easy. You could also just close the terminal window and easily escape that way.

[–] [email protected] 6 points 10 months ago

I think someone else mentioned this but just run vimtutor in your command line for a pretty exhaustive tutorial.

[–] [email protected] 5 points 10 months ago (2 children)

Doesn't work with laptops.

[–] [email protected] 10 points 10 months ago

It does, but it takes longer

load more comments (1 replies)
[–] [email protected] 4 points 10 months ago

:killall -9 vim

[–] [email protected] 4 points 10 months ago

Type :q to exit.

load more comments
view more: next ›