Question

I've been using Vim for a several years. And now I want to give a try to Emacs.

For Vim I have a general config file (here) where I'm overriding defaults (e.g. hey, Vim, show me the line numbers; save more history, don't create these stupid backup files, etc...)

I want the same thing for Emacs. While searching, the best thing I've found is better-defaults.el from technomancy. I'm still digging in Prelude and Emacs-Starter-Kit sources, but there are too many overrides and plugins.

So, what I want:

  • ability to see a list of variables, which I can customize (e.g. indent-tabs-mode or newline-and-indent). I know about C-h v variable-name but this command requires me to know a name of variable, but I want a list of them
  • sample config file for Emacs which sets helpful defaults with comments for each command
Was it helpful?

Solution

  1. For your first question: M-x customize-option.

    C-h v TAB is not what you want, as it shows you also non-option variables (e.g., internal variables).

    However, if you load library help-fns+.el then C-u C-h v TAB shows you only the user options (in buffer *Completions*).

  2. My advice would be to not look for an existing "sample config file", if you intend to start with it, as opposed to just seeing how another user redefines things. And for help with the latter, I would still recommend the Emacs manual over looking at someone elses init file. Especially to start with.

    However, if you really want to look at init files from other users then this is the place to start. (And this is a good place to start, other than the manual (which is the best place), to learn about customizing Emacs.)

  3. Finally, my (unsolicited) advice wrt learning Emacs, including customizing, is to start by not customizing it at all. I say that without irony as one who has heavily customized Emacs.

    If you want to "get it", i.e., to get a feel for the Emacs design and what makes it different, then let yourself get used to Emacs as it is out of the box -- for maybe a month or so. At that point you can think about customizing, and your customizations are likely to be much wiser (in your own terms, i.e., for whatever it is that you want).

    Another way of putting this is that until you know Emacs a bit, you really do not know what it is that you want or need in terms of customization. In particular, it would be a mistake, IMO, to start out by trying to think of Emacs in terms of Vim or trying to make Emacs do what you've done in Vim. There is plenty of time for that later, if, based on understanding Emacs, you really do want to do that.

  4. Welcome to Emacs. Enjoy.

OTHER TIPS

I'm going to take a reasonable dissent from Drew's excellent answer, there are some things you really ought to set in your emacs-file immediately, that aren't set out of the box that you really ought to set.

Issue number 1: THAT $(generate-swearing) BELL!

The bell will ding like a madman. That's annoying. You can turn it off. In your init-file, do this:

(setq visible-bell 1)

Issue number 2: Emacs has an interesting view of backup files. If you edit a file, say "foo.txt", emacs will create little backups of the file with the name "foo.txt~" in the same directory. This is annoying as all hell, and you can fix it by doing this:

(setq backup-directory-alist '(("" . "~/.emacs.d/emacs-backup")))

Issue number 3: Emacs uses C-w differently than bash does, and that's a bit annoying. C-w usually deletes a word backwards. By standard in emacs, it deletes the marked region. That's a bit silly. It is better to do something like this:

;; This is my preference, your mileage may vary.
(global-set-key (kbd "C-x C-k") 'kill-region)
(global-set-key (kbd "C-x k") 'kill-buffer)
(global-set-key (kbd "C-w") 'backward-kill-word)

Issue number 4: Alt-X is a clunky way of running an interactive command. It is better to do something like this instead, avoid your hand cramping up all the time.

(global-set-key (kbd "C-x C-m") 'execute-extended-command)
(global-set-key (kbd "C-x C-m") 'execute-extended-command)

You also may want to check out Steve Yegge's Effective Emacs: https://sites.google.com/site/steveyegge2/effective-emacs It's pretty amazing. One thing to note though is that the caps-lock to ctrl thing is also available through a microsoft tool here: https://learn.microsoft.com/en-us/sysinternals/downloads/ctrl2cap This is better than the manual hack Yegge suggests, and you can turn it off if you don't like it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top