Hacker News new | ask | show | jobs
by pvaldes 1351 days ago
Is all about muscular memory, so you need to repeat and repeat, and take your time to develop it. Is normal not to grasp it after a few hours using the program. Nobody expects taking one karate class and exit being a master of katas.

First emacs kata should include this very simple concepts

1.Opening a file (the easy way) -> extra simple. Type "emacs /path/to/my-file" in a terminal. If a file with this name does not exist in the directory, a file image in memory will be created for it.

2.Do something with the file. Edit the file, see the image, read the pdf that you opened or take a look to the pdf code. Just use the keyboard and type something.

3.Close your file. Type Control and X at the same time. Then type C (for close): "ctrl-x c"

> "Your buffer (image in memory of the file) has been modified. Do you want to save the changes?"

Not: type N.

Yes: type Y.

Take in mind that if you open an extant file and type N, the old file will not be modified (you have still a file with this name).

But if you open a new file and type N, the image in memory will be discarded without a trace. Don't look for an empty file with that name in your directory. Will materialize only after you save it once. You can save an empty file.

Congratulations you are using emacs now. Here is your white belt.

Any time invested on using the program will payback later generously

2 comments

This is exactly how I learned Vim. Afterwards I bundled it all together into a book (shameless self promotion I know)

The book is a weekly practice schedule that takes ten minutes a day to build up muscle memory for variety of techniques on premade files. It starts with the absolute basics, but builds all the way to advanced regular expressions with lookahead and lookbehind. By the end it covers the management and editing of marks, registers and macros.

It's amazing what a difference it makes to have muscle memory with macros and registers. Of course one can devise their own katas from the docs, but I just did the legwork of manufacturing scenarios to practice them.

https://leanpub.com/deliberatevim

Yes, except the keystroke to "close a file" is C-x k (for kill buffer).

Like you said, muscle memory. It's not surprising that you didn't remember the exact name of the keystroke because normally, you just do it.

This is also related to one of those sharp edges of Emacs that can cut you. "C-x c" is pretty close to "C-x C-c", which is the shortcut to exit Emacs. If for some reason, you DID mean to type "C-x c", it's easy to let your Ctrl finger linger a little too long and hit "C-x C-c" instead. And since x and c are next to each other on a US keyboard, it's also very easy (for me) to hit x and c at the same time with a single finger motion. The odds go up since so many actions start with "C-x"

(setq confirm-kill-emacs 'y-or-n-p) is one of the most important configs to start with, IMO. Or if you don't want to learn/use elisp, the equivalent Customize setting:

Options > Customize Emacs > Top-Level Customization Groups > Convenience > Confirm Kill Emacs

Generally, if I have unsaved work Emacs prompts me to save, so I can C-g out then if I fat-finger kill-emacs.
I think that killing the entire app is jarring enough that it should never happen accidentally, regardless of unsaved work. It would be especially harmful for newer users, since they will find it harder to relax and feel comfortable with Emacs. But even for experienced users, Emacs state that you would want to preserve goes far beyond unsaved edits. Expensive startup computation, open buffers, window arrangement, ongoing rgrep operations, etc.
Ctl-x k when you have more than one file opened. Ctl-x C is faster and more easy in this particular case.

Hum, I see. I stand corrected. It seems that all this time I was typing Ctl-x Ctl-C instead. I never use copy in emacs