A lot of you know that I'm a hardcore Vim fanatic. However, I'm also burnt out right now, so I'm mixing things up. I'm going to switch to Emacs for a while. Help me out by leaving a comment with a couple of your favorite "power" commands.
I'm especially interested in figuring out how to tell Emacs things like "When coding in C, the tab key indents 4 spaces, but change every list of 8 spaces into a real tab. Also, when I go down a line, indent to exactly where I was on the line above." Intelligent indentation is nice, but for cases where it doesn't do what I want, I'd like it to still be helpful. In Vim, I can just enter ":set shiftwidth=4 tabstop=8 autoindent".
Vi is like have capslock for your control key.
I'm especially interested in figuring out how to tell Emacs things like "When coding in C, the tab key indents 4 spaces, but change every list of 8 spaces into a real tab. Also, when I go down a line, indent to exactly where I was on the line above." Intelligent indentation is nice, but for cases where it doesn't do what I want, I'd like it to still be helpful. In Vim, I can just enter ":set shiftwidth=4 tabstop=8 autoindent".
Vi is like have capslock for your control key.
Comments
http://www.emacswiki.org/cgi-bin/wiki/IndentingC
Andrea
Hahaha, thanks ;)
There are dozens and dozens of options. Don't actually add lisp to your .emacs, i.e. (setq c-default-style), until you've messed around with customize first. Otherwise you will stomp all over your customize-set options.
second, my favorite power command is:
C-x C-c
vim
I say that as a long time emacs/vim switch hitter, which you are aware of.
Third, opening new window and stuff is fun:
C-x w
C-x 5 2 (in x11, etc)
C-x 5 0
For C/C++ vim is really cool, :mak and then you have the quickfix mode to go fix your compile errors.
:make install works too.
But I don't want to start another religion war :)
(autoload 'python-mode "python-mode" "Python editing mode." t)
(setq auto-mode-alist (cons '("\\.py$" . python-mode) auto-mode-alist))
(setq py-indent-offset tab-width)
(setq py-smart-indentation t)
(setq python-mode-hook
'(lambda ()
"python mode hook override."
(setq tab-width 4)
(setq py-indent-offset 4)
)
)
Your HTML cannot be accepted: Tag is not allowed:
I'm using Aquamacs. I get "C-x SPC is undefined".
Hmm, it looks like rectangle mode is documented here: http://blog.interlinked.org/tutorials/emacs.html
Thanks!
(defun indent-or-expand (arg)
"Either indent according to mode, or expand the word preceding
point."
(interactive "*P")
(if (and
(or (bobp) (= ?w (char-syntax (char-before))))
(or (eobp) (not (= ?w (char-syntax (char-after))))))
(dabbrev-expand arg)
(indent-according-to-mode)))
(defun my-tab-fix ()
(local-set-key [tab] 'indent-or-expand))
;;and this to activate it for all the modes I want it in:
(add-hook 'c-mode-hook 'my-tab-fix)
(add-hook 'sh-mode-hook 'my-tab-fix)
(add-hook 'emacs-lisp-mode-hook 'my-tab-fix)
(add-hook 'python-mode-hook 'my-tab-fix)
(add-hook 'rest-mode-hook 'my-tab-fix)
You don't need C-x SPC for the rectangle commands, you can just use C-SPC at the beginning of the rectangle to set mark and move to the other place before running the rectangle commands; they automatically act on the rectangle.
Stupid autocomplete is M-/ although it does look in other buffers as well if it doesn't find it in the current buffer.
Hope this helps,