Questions tagged [emacs]

GNU Emacs is an extensible, customizable, self-documenting text editor, which can be extended with Lisp code. Although Emacs is a general-purpose editor, questions may be on-topic here if they are about extending Emacs itself (usually by writing Emacs Lisp functions) or about specific programming modes. Otherwise (and perhaps also in those cases), consider asking your question on Emacs Stack Exchange.

GNU Emacs is an extensible, customizable text editor. Begun in the mid-1970s as a set of macros on top of TECO, it was re-written using C and Emacs Lisp to provide portability and an extendable interface. It continues to be actively developed today.

Emacs provides context-sensitive editing modes with syntax coloring, is self documenting, has full Unicode support and extensions to do almost anything. It similarly has extensive packaging support through the built-in package.el package.

Emacs' package selection includes color themes, language-specific editing modes, RSS readers, email clients, web browsers, etc. Die-hard Emacs users do almost everything from within Emacs: write, compile, run and debug code; read/compose email; browse the web; do project planning, etc. Some other editors, like Visual Studio or Eclipse, provide Emacs key bindings.

Questions about using and configuring Emacs, not specific to programming, are off-topic for Stack Overflow, but they may be suitable for Emacs Stack Exchange. Questions about extending Emacs using Lisp or other languages, or about programming modes, are usually on-topic here.

Useful Links

Wisdom from Stack Exchange

Books

17686 questions
108
votes
7 answers

Get font face under cursor in Emacs

I've been developing my own custom color theme, and it'd be really useful if I could get a list of font-faces affecting the text under the cursor. Something like Textmate's show current scope command. That would save me the trouble of doing M-x…
thedz
  • 5,496
  • 3
  • 25
  • 29
108
votes
20 answers

What specific productivity gains do Vim/Emacs provide over GUI text editors?

This isn't meant as a troll or flamebait or anything like that. I've been using Vim as my console-editor of choice for a couple months now (for editing configuration files while in my terminal), but I don't think I could stand it for my normal,…
Adam Plumb
  • 3,738
  • 8
  • 35
  • 34
107
votes
11 answers

Close all buffers besides the current one in Emacs

How do I close all but the current buffer in Emacs? Similar to "Close other tabs" feature in modern web browsers?
Sridhar Ratnakumar
  • 81,433
  • 63
  • 146
  • 187
107
votes
8 answers

How to determine operating system in elisp?

How do I programmatically determine which OS Emacs is running under in ELisp? I would like to run different code in .emacs depending on the OS.
ljs
  • 37,275
  • 36
  • 106
  • 124
106
votes
13 answers

Emacs on Mac OS X Leopard key bindings

I'm a Mac user and I've decided to learn Emacs. I've read that to reduce hand strain and improve accuracy the CTRL and CAPS LOCK keys should be swapped. How do I do this in Leopard? Also, in Terminal I have to use the ESC key to invoke meta. Is…
Kyle Cronin
  • 77,653
  • 43
  • 148
  • 164
105
votes
16 answers

How to scroll line by line in GNU Emacs?

To put it simply, I'm trying to get scrolling in emacs like in vim and most other editors; when I'm for example, two lines from the bottom/top, and I press down/up (Ctrl-p,n, ↑,↓) it goes only one line up or down, not half the screen.
Rook
  • 60,248
  • 49
  • 165
  • 242
102
votes
9 answers

Move line/region up and down in emacs

What is the easiest way to move selected region or line (if there is no selection) up or down in emacs? I'm looking for the same functionality as is in eclipse (bounded to M-up, M-down).
fikovnik
  • 3,473
  • 3
  • 28
  • 29
101
votes
5 answers

Emacs: reopen buffers from last session on startup?

Every day I start up emacs and open the exact same files I had open the day before. Is there something I can add to init.el file so it will reopen all the buffers I was using when I last quit emacs?
kris
  • 23,024
  • 10
  • 70
  • 79
101
votes
6 answers

What is the best way to open remote files with emacs and ssh

I connect to the remote machine with ssh user@192.168.1.5. When I need to open a file in the remote machine I do, e.g., emacs /usr/share/nginx/html/index.html and that opens the index.html file in the shell. I noticed that some emacs commands work…
Zeynel
  • 13,145
  • 31
  • 100
  • 145
100
votes
15 answers

How to launch GUI Emacs from command line in OSX?

How do I launch GUI Emacs from the command line in OSX? I have downloaded and installed Emacs from http://emacsformacosx.com/. I'll accept an answer fulfilling all of the following criteria: The emacs window opens in front of my terminal…
Johan Walles
  • 1,447
  • 2
  • 15
  • 23
99
votes
13 answers

Emacs, switch to previous window

In Emacs, C-x o takes me to the next window. What keyboard macro takes me to the previous window in Emacs?
Roger C S Wernersson
  • 6,362
  • 6
  • 34
  • 45
99
votes
8 answers

How can I select or highlight a block in Emacs?

I want to select or highlight a block in Emacs without using the mouse, but doing it from the keyboard like Vim's visual mode. What is the easiest way to do this from a keyboard?
systemsfault
  • 15,207
  • 12
  • 59
  • 66
99
votes
3 answers

"Wrong type argument: commandp" error when binding a lambda to a key

I am getting a "Wrong type argument: commandp, (lambda nil (forward-line 5))" here. (global-set-key [?\M-n] (lambda () (forward-line 5))) What is the error? I'm fairly sure it's simple & I'm missing something obvious.
Paul Nathan
  • 39,638
  • 28
  • 112
  • 212
98
votes
9 answers

Bash autocompletion in Emacs shell-mode

In the GNOME Terminal, Bash does smart auto-completion. For example apt-get in becomes apt-get install In Emacs shell-mode, this auto-completion doesn't work, even after I explicitly source /etc/bash_completion. The above example sticks as in…
Chris Conway
  • 55,321
  • 43
  • 129
  • 155
96
votes
9 answers

How do I change Emacs' default font size and font type?

I am using Emacs 23.3. How can I change the font size and font type?
demonchand
  • 11,091
  • 6
  • 21
  • 25