关于tab缩进设置,我想用下面的设置,放进spacemacs里面错误,有大神帮弄一下吗?
理论上加这种配置不会产生冲突的。
所以,要么是你贴方法的不对,要么是因为这文章时间有点久和现在的 Emacs 不兼容。
请描述下是什么错误,以及你是怎么贴的。
找到了他的github地址。copy下来就行了。
在visual下,为什么 S-TAB无法作用
我的设置如下:
;;** tab key & indent
(setq tab-always-indent 'complete)
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq tab-stop-list
(loop for i from 4 to 120 by tab-width collect i))
;;*** abs-indent: to mimic other simple editor's indent/unindent
;; unlike emacs' default settings, this would not use syntax-based indent, but:
;; - if region selected, indent/unindent the region (tab-width)
;; * the region mark would not deactivated automatically
;; - if no region selected, <TAB> would
;; * if cursor lies in line leading, always indent tab-width
;; * if cursor lies in word ending and `tab-always-indent' is `complete', try complete
;; * otherwise, always insert a TAB char or SPACEs
;; - if no region selected, <S-TAB> would
;; * if cursor lies in line leading, always unindent tab-width
;; * otherwise, the cursor would move backwards (tab-width)
;; Note: this implementation would hornor `tab-always-indent', `indent-tabs-mode' and `tab-with'.
(defvar abs-indent-complete-function 'dabbrev-expand
"The function used in `abs-indent' for completion.")
(make-variable-buffer-local 'abs-indent-complete-function)
(defun abs-indent (arg)
"Absolutely indent current line or region. Mimic other editors' indent."
(interactive "P")
(let ( (width (or arg tab-width)) )
(if mark-active
;;DONE: how to restore region after `indent-rigidly'
(let ( (deactivate-mark nil) )
(indent-rigidly (region-beginning) (region-end) width))
(let ( (pt (point))
(pt-bol (line-beginning-position))
(pt-bol-nonws (save-excursion (back-to-indentation) (point))) )
(if (<= pt pt-bol-nonws) ;;in leading whitespaces
(progn
(back-to-indentation)
(if (looking-at "$") ;;all chars in this line are whitespaces or tabs
(indent-to (+ (current-column) width))
(progn
(indent-rigidly pt-bol (line-end-position) width)
(back-to-indentation))))
(if (and (eq tab-always-indent 'complete)
(looking-at "\\>"))
(call-interactively abs-indent-complete-function)
(if indent-tabs-mode
(insert-char ?\t 1)
(insert-char ? width))))))))
(defun abs-unindent (arg)
"Absolutely unindent current line or region."
(interactive "P")
(if mark-active
(let ( (deactivate-mark nil) )
(indent-rigidly (region-beginning) (region-end) (- tab-width)))
(let ( (pt (point))
(pt-bol (line-beginning-position))
(pt-bol-nonws (save-excursion (back-to-indentation) (point))) )
(if (> pt pt-bol-nonws) ;;in content
(move-to-column (max 0 (- (current-column) tab-width)))
(progn
(back-to-indentation)
(backward-delete-char-untabify (min tab-width (current-column))))))))
(defun hack-tab-key ()
(interactive)
(local-set-key (kbd "TAB") 'abs-indent)
;; S-TAB not work when in visual mode
;; (local-set-key (kbd "S-TAB") 'abs-unindent)
(local-set-key (kbd "C-c TAB") 'abs-unindent)
)
;; to used it
;; (add-hook 'prog-mode-hook 'hack-tab-key)
(add-hook 'text-mode-hook 'hack-tab-key)
(global-set-key (kbd "M-i") 'abs-indent)
;; S-TAB not work when in visual mode
;; (global-set-key (kbd "S-TAB") 'abs-unindent)
(global-set-key (kbd "C-c TAB") 'abs-unindent)
你要了解如何定义 Evil 的按键。
全局按键在输入模式会被 Evil 覆盖的。