2011-08-19 68 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(製表符到製表符停止)將帶您到下一個製表位。