Emacs cc模式选项卡行为

pic*_*c11 4 emacs cc-mode

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

Rup*_*ick 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)))
Run Code Online (Sandbox Code Playgroud)

然后,您需要将标签插入与类似的内容绑定

(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)
Run Code Online (Sandbox Code Playgroud)

我多年没有使用过MS Visual Studio,所以我不确定这是不是你想要的,但希望很清楚如何修改.