Vim user here. The only way to exit vim is to pray to the Vim gods and sacrifice your first born, hoping that they’ll cause a cosmic ray to hit the right spot in the memory to flip the right bit that causes it to exit. There are no alternatives.
I am non-serious, I just don’t like vim (or emacs; if I’m editing a text file in a terminal I want nano, or I append manually with pipes as Linus intended).
Most of my systems have X11 and some basic GUI text editor, my server is the exception that proves the rule. There is generally no actual reason to use Vim except liking Vim, or wanting to learn to like Vim.
For those that do like Vim, or want to learn it for historical reasons? Good on you, have fun.
The main reason for using (neo)vim is motions and text objects. Pretty cool to be able to type cxia, ]a, cxia to swap two function parameters in code. Or daf to delete a whole function.
Even just f to jump to a specific character later in the line, or t to jump up to that character are absolutely life changing.
I love love love editing HTML in neovim with the ability to do stuff like dst for “delete surrounding tag” or St<div class=“something”> to surround the current selection with a new tag. I have yet to find another editor that can do stuff like that with just a couple key presses.
These is one of the oldest Linux memes. No, they aren’t serious. I have a hard time believing anyone here doesn’t actually know how to exit vim properly.
vimtutor, which I believe is installed with vim by default
Edit: My brain apparently inserted an extra word that made it seem like you were seeking said program. Leaving it though for those wondering in the future.
Yeah, but imo the best way to learn vim is to do it as you go. You only really need to know getting in and out of insert and how to write and quit. Once you’ve got that, if you wanna do something and think there’s probably a better way than moving there with the arrow keys, look it up on the Internet, remember the thing, do it a few times and you’ve learned a new thing about vim. “Surely there’s a search and replace function” yeah, is substitute with the s command. “I wanna navigate quicker within lines” use f, t and their capital versions. Combine with the quickscope plugin and you’re golden. Learn the stuff you want to use, don’t memorize commands you don’t need
Escape first, because it wants to keep you inside the matrix and you need to tell it you are trying to escape
q!
Because you probably don’t want to save whatever you’ve accidentally done to that file trying to quit, and you have to add an exclamation point because unless you yell loudly at vim it won’t listen
Not really. I believe : is the “true” builtin. So it’s like running a program that exits with zero and writes nothing to stdout. The >> streams the empty stdout into the named file.
I’m betting that’s why none ever materialized. Most tools that can manipulate a file, can also create that file first, so there’s just never been a usecase.
Right-clicking the desktop to create a new txt file in Windows feels so natural, but I can’t really think of any time you’d want to create a new file and do nothing with it in a CLI.
One use case is if you’re running a web server that is configured to return a “maintenance” page instead of the live site if a particular file exists. Which is actually pretty cool because then you don’t have to update the config when you need to do something or let your users get a bunch of 502 errors, you just touch maintenance and you’re good.
Yeah. It could just as well have issued a file not found error when you try to touch a nonexistent file. And we would be none the wiser about what we’re missing in the world.
“Do one thing and do it very well” is the UNIX philosophy after all; if you’re 99% likely to just create that missing file after you get a file not found error, why should touch waste your time?
I sometimes use cat to concatenate files. For example, add a header to a csv file without manually copy and paste it. It’s rare, but at least more frequent than using touch.
Yes, when you are for example checking if the permissions in the directory are correct, or if you want to check if your nfs export is working. It’s one of those commands that once you know it exists, you WILL find a way to use it.
It is short for concatenate, which is to join things together. You can give it multiple inputs and it will output each one directly following the previous. It so happens to also work with just one input.
When you updated a Django server, you were supposed to touch the settings.py file so the server would know to reload your code. (I haven’t used any for a long time, so I don’t know if it’s still the procedure.)
Ahhhhh, fuck. I’m quite noob with linux. I got into some rabbit hole trying to read the docs. I found 2 man pages, one is cat(1) and the other cat(1p). Apparently the 1p is for POSIX.
If someone could help me understand… As far as I could understand I would normally be concerned with (1), but what would I need to be doing to be affected by (1p)?
The POSIX standard is more portable. If you are writing scripts for your system, you can use the full features in the main man pages. If you are writing code that you want to run on other Linux systems, maybe with reduced feature sets like a tiny embedded computer or alternates to gnu tools like alpine linux, or even other unixes like the BSDs, you will have a better time if you limit yourself to POSIX-compatible features and options – any POSIX-compatible Unix-like implementation should be able to run POSIX-compliant code.
This is also why many shell scripts will call #!/bin/sh instead of #!/bin/bash – sh is more likely to be available on tinier systems than bash.
If you are just writing scripts and commands for your own purposes, or you know they will only be used on full-feature distributions, it’s often simpler and more comfortable to use all of the advanced features available on your system.
If you execute a binary without specifying the path to it, it will be searched from the $PATH environment variable, which is a list of places to look for the binary. From left to right, the first found one is returned.
You can use which cat to see what it resolves to and whereis cat to get all possible results.
If you intentionally wants to use a different binary with the same name, you can either directly use its path, or prepend its path to $PATH.
I mean, timestamps aren’t really all that useful. Really just if you do some stuff with makefiles but even then it’s a stretch. I did once use cat for it’s intended purpose tho, for a report. We split up the individual chapters into their own files so we have an easier time with git stuff, made a script that had an array with the files in the order we wanted, gave it to cat and piped that into pandoc
I used it recently to update the creation date of a bunch of notes. Just wanted them to display in the correct order in Obsidian. Besides that though, always just used it for file creation lol
Touch is super useful for commands that interact with a file but don’t create the file by default. For example, yesterday I needed to copy a file to a remote machine accessible over ssh so I used scp (often known as “secure copy”) but needed to touch the file in order to create it before scp would copy into it
Creating an empty file is one of its intended purposes. Unix commands were designed as multi-purpose primitives, so they could be reused and composed to handle many different tasks. The touch command is no exception.
Everyone who works on making software is a developer, even people who don’t program at all. people who make art for software work in software development. A “coder” only writes code. It’s more of a task than a job. A software engineer does technical design and probably also codes.
programmer_humor
Newest
This magazine is from a federated server and may be incomplete. Browse more on the original instance.