質問

Pressing tab multiple time doesn't move text to the right. Is there is a way to make it behave like Visual Studio's smart indent? First tab indents, subsequent tabs move text to the next tab stop. Thank you.

役に立ちましたか?

解決

Something like this?

(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)))

You'll then want to bind tab insertion with something like

(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)

I haven't used MS Visual Studio in many years, so I'm not sure whether this is exactly what you're after, but hopefully it's pretty clear how to modify.

他のヒント

M-i (tab-to-tab-stop) takes you to the next tab stop.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top