类似vscode的
C-[ (该行向前缩进一个tab(4个空格))
C-] (该行回退缩进一个tab(4个空格))
搞了好久的emacs的缩进都不尽人意啊。
类似vscode的
C-[ (该行向前缩进一个tab(4个空格))
C-] (该行回退缩进一个tab(4个空格))
搞了好久的emacs的缩进都不尽人意啊。
我之前也有这个问题!后来因为用EVIL所以直接选中后通过 <
和 >
做缩进了。 回头试一试这个包。
我刚好也写了一个,一直在用,加 C-u
表示回退:
(defun my/indent-4-space (backward)
"Indent/dedent region or insert/delete 4 sapce."
(interactive "P")
(cond ((and (use-region-p) backward)
(replace-regexp "^ " "" nil (region-beginning) (region-end)))
((and (use-region-p) (not backward))
(replace-regexp "^" " " nil (region-beginning) (region-end)))
(backward
(let ((spaces 4)
char)
(while (> spaces 0)
(setq char (char-after (point)))
(cond ((char-equal (char-after (point)) 32) ; delete a space char
(delete-char 1)
(setq spaces (- spaces 1)))
((char-equal (char-after (point)) 9) ; delete a tab char
(delete-char 1)
(setq spaces (- spaces 4)))))))
(t (insert " "))))