2011-08-19 66 views
4

多次按下选项卡不会将文本向右移动。有没有办法让它的行为像Visual Studio的智能缩进?第一个选项卡缩进,后续选项卡将文本移动到下一个制表位。谢谢。Emacs cc模式选项卡行为

回答

5

像这样的东西?

(defun even-more-tabby-indent (&optional arg) 
    "This indent function tries to be more like Microsoft's IDEs 
than `C-INDENT-COMMAND' and does the following: If we're at the 
beginning of the line or `C-TAB-ALWAYS-INDENT' is true or `ARG' 
is non-nil, indent like a sensible text editor. Otherwise the 
user probably WANTS MOAR TABS. So call `C-INSERT-TAB-FUNCTION'." 
    (interactive "P") 
    (if (or c-tab-always-indent (bolp) arg) 
     (c-indent-command arg) 
    (funcall c-insert-tab-function))) 

你会再想要标签插入绑定的东西,如

(defun setup-tabby-indent() 
    (local-set-key (kbd "<tab>") 'even-more-tabby-indent) 
    (setq c-tab-always-indent nil)) 

(add-hook 'c-mode-hook 'setup-tabby-indent) 

我没有使用微软的Visual Studio的许多年,所以我不知道这是否正是你'之后,但希望它很清楚如何修改。

+0

啊,正如Lazylabs说的,也许你想用tab-to-tab-stop而不是我建议的(funcall c-insert-tab-function)。 –

1

M-i(制表符到制表符停止)将带您到下一个制表位。