Lurker News
A command line trick, a random factoid, anything that’s interesting to you.

Comments (762) 128 threads

Earlier comments
arnarbi1 reply#
xp is a quick way in vi to swap two adjacent characters (a common typo correction)

Ctrl-T does the same in emacs, and also in readline based programs like bash, as well as everywhere on macOS.

_zywo1 reply#
> xp

I always thought the fact that Vim had automatic buffer copying and forced me to use "0p instead of p was really annoying. Looks like there is an actual reason for it after all :)

arnarbi#
(Apologies if I’m misunderstanding and you already know this.)

Not specifying a register (e.g. "0) just means the commands, including x and p, will use the " register, aka the unnamed register. By itself, p is equivalent to ""p.
:reg shows you all the registers and their current contents.
This seems like a good description: https://www.brianstorti.com/vim-registers/
Edit: Oh I guess you are saying it was unexpected that delete or change commands clobber yanked contents of the unnamed register.

darrelld3 replies#
In your terminal Ctrl+a will return you to the start of whatever line you have typed, and ctrl+e will return you to the end.
Jtsummers1 reply#
This is if you have emacs-based keybindings (which is the default). M-f/M-b (Meta, often the alt key or option key) will move forward/backward a full word. C-f/C-b moves forward/backward a character. C-w kills the previous word (if you're in the middle of a word it leaves everything from the cursor to the end intact).

C-r will search backward in your history allowing you to type partial matches (like, "I know I compiled foo.c, but what options did I use?" type `C-r foo.c` and repeatedly type C-r until I find the compiler command I used).
https://www.gnu.org/software/bash/manual/html_node/Bindable-... - for a lot more options
You can switch to vi keybindings with `set -o vi`.

tetris112 replies#
Aren't all terminal bindings emacs-based, since they inherit from libreadline?
sph#
zsh doesn't use readline
O_H_E#
By default, yes. (Well, its not the terminal but the shell that takes input) but readline has support for vi bindings configuration
tmaly#
I use Ctrl+u if I think I might have added a typo in a password and have not yet typed enter
arnarbi1 reply#
This also works in any native text input on macOS.
primarydonkey1 reply#
On macOS, I also use ctrl+x go to the beginning of the line.
exikyut#
TIL there are scenarios where ^X doesn't just cut text.

(Never used macOS. Welp. Guess I have a lot of relearning to do.)

eps1 reply#
Closely related -

In theory, there's no difference between the theory and the practice.
In practice, there is.

O_H_E#
Oohh, that is good. Actually made me laugh
seesaw#
Related: 80% of the work is done by 20% of the team :)
rawoke0836003 replies#
ok I'll have a go !

Here is my favorite mental-model for problem solving (and my favorite analogy)
So I have this problem:
I love eating scramble eggs, I hate cleaning up the pan and have been trying over the years many different techniques to make sure the egg's doesn't stick to the pan. (No I don't want teflon thanks).
So I tried different oils, temperatures and techniques, all with the goal of getting those delicious eggs not to stick in my pot/pan afterwards.
Then one day it hit me, I'm solving the wrong problem. The problem to be solved is not "EGGS NOT STICKING TO PAN", it's "FINDING A BETTER WAY TO CLEAN" the pan !
And I have found it, it's using a different type of plastic-scrubber. It looks like steel-wool, but it's all plastic.
So whenever I'm stuck on a problem for too long, I try and model the problem as an "eggs-in-pan" problem statement.

gonzo41#
Try cooking on a cast iron pan that's been seasoned, i cook eggs on these and I can clean it in about ~1 minute with a soft sponge.
ThinkBeat#
I use a cast iron pan for the most part.

First I put oil in the pan and let it heat up. Once it is hot, I pour the scrambled egg on it. Use my spoon, fork, whatever to distribute and turn. then I tip over the pan get the eggs onto my plate.
My pan has a nice feature to make pouring it out easier.
Usually nothing has stuck to the pan.
It is key to heat the pan and the oil first.
If something sticks, whilst still hot, pour some water on it. It will result in a satifsying bubbling that usually will get any residue out.
Dry with a (paper) towel or whatever else you use.
I usually drip a little oil in the pan before I put it away.
If that sounds complicated it realy is not. Once you do it a few times it takes up little time and is fairly reliable.
Another good tip is make sure you use the right oil. Use oil that is mean for high heat.

morninglight1 reply#
I had a girlfriend in Amsterdam who taught me to make scrambled eggs in a double boiler. This keeps the eggs at the temperature of boiling water. The result is so much better (light and fluffy) that you will never use your skillet again. I have heard that there are special large double boilers that are used to prepare scrambled eggs for restaurants, but I have never seen one.

.

Beldin#
For anyone wondering what a "double boiler" is: it's cooking au bain marie.

Load more comments