My preferred way to use Emacs is to open it to edit a particular filetype with a custom init file. Most commonly, this is a .org file that I'm opening with a script. The primary advantage of using a custom init file is that you can optimize Emacs for one type of file without causing conflicts for other modes. Emacs is almost unusable in its raw form. Duplicating a line requires this mess: C-a C-SPACE C-n M-w C-y
. Obviously, nobody wants to deal with that. It's easier to select, copy, and paste the line than to type that - assuming you can even remember it.
I open .org files with a command like this:
emacs -q -l custom.el foo.org
This opens file foo.org using custom.el as the init file. Inside custom.el are the lines:
(setq inhibit-startup-screen t)
(global-set-key (kbd "C-c x") 'org-cut-special)
(global-set-key (kbd "C-c c") 'org-copy-special)
(global-set-key (kbd "C-c v") 'org-paste-special)
(cua-mode t)
The first line makes Emacs open without the annoying startup screen that for some reason opens by default no matter what. You'll go crazy if you have to deal with it every time you open a .org file, so get rid of it. Lines 2-4 make it possible to cut, copy, and paste items in your outline. This is really handy for moving content around. Line 5 is by no means necessary, but I always forget which of C-w
and M-w
is copy and which is paste. cua-mode gives copy, cut, and paste the normal shortcuts of C-c
, C-x
, and C-v
.
This minimal configuration file is sufficient to make me extremely productive editing .org files that contain project information, checklists, and any other information I need to track.
Top comments (3)
“ Duplicating a line requires this mess: C-a C-SPACE C-n M-w C-y. Obviously, nobody wants to deal with that. It's easier to select, copy, and paste the line than to type that”
that “mess” happens to be how you select, copy and paste a line.
Well, that's true, but I meant it's even worse than the disaster of selecting, copying, and pasting with the mouse. In Geany it's just C-d.
anyway, with default config I’d use
C-a C-k C-k C-y C-y
(goto beginning of line, kill line, including newline, then yank twice. )
instead of selecting the line and copypasting.
and instead of different init file, why not use
(define-key org-mode-map (kbd "C-c x") 'org-cut-special)
in normal init to have that key in just org-mode?