![](/img/trans.png)
[英]emacs C/C++ indentation: different for pre and post comments // or: how can I make certain comments like //^ be indented extra?
[英]How can I make emacs indentation behaviour like phpstorm/eclipse?
我是emacs的新手,並拼命嘗試使其表現出我過去幾年使用IDE所習慣的方式。
我喜歡它正在做的很多事情,但是我對它的縮進實踐持懷疑態度。
我想要的是:
我設法通過https://github.com/zorgnax/regtab獲得2/4。 不幸的是,該解決方案破壞了neotree中的路徑解析。
編輯:認為有必要為此顯示我的.emacs配置
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(add-to-list 'load-path "~/.emacs.d/plugins/")
(load "regtab.el")
(define-globalized-minor-mode my-global-regtab-mode regtab-mode
(lambda() (regtab-mode 1)))
(my-global-regtab-mode 1)
(when (fboundp 'electric-indent-mode) (electric-indent-mode -1))
電動縮進模式被關閉,因為如果我以它認為是“無效的方式”縮進一條線,然后按RET,它將“更正”我的縮進。 當我使用Cy時,它對整個文件執行相同的操作
您想使'invalid'縮進的原因是某些庫使用了本質上無效的html / js語法。
EDIT2:替換
(when (fboundp 'electric-indent-mode) (electric-indent-mode -1))
與
(setq-default electric-indent-inhibit t)
有幫助。 它不再將怪異的壓痕壓在我身上,但現在在按下RET時至少會略微壓痕,而在使用Cy時不再破壞我的壓痕。
現在剩下的就是要以某種方式實現regtab的功能,而不必搞砸Mx命令的路徑解析。
好吧,我有點想出自己的東西了。 如果您有比我要列出的解決方案更好的解決方案,請提供它們。
1)修復糟糕的emacs縮進:獲取此文件: https : //github.com/zorgnax/regtab將其放在〜/ .emacs.d / plugins /中(此文件不存在,創建它。)
在您的〜/ .emacs文件中,添加以下內容:
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(add-to-list 'load-path "~/.emacs.d/plugins/")
(load "regtab.el")
(define-globalized-minor-mode my-global-regtab-mode regtab-mode
(lambda() (regtab-mode 1)))
(my-global-regtab-mode 1)
(when (fboundp 'electric-indent-mode) (electric-indent-mode -1))
(setq-default electric-indent-inhibit t)
2)解決上述步驟的副作用:安裝hippie-expand將以下內容添加到〜/ .emacs文件中
(global-set-key (kbd "C-M-/") 'my-expand-file-name-at-point)
(defun my-expand-file-name-at-point ()
"Use hippie-expand to expand the filename"
(interactive)
(let ((hippie-expand-try-functions-list '(try-complete-file-name-partially try-complete-file-name)))
(call-interactively 'hippie-expand)))
現在,當您想在Mx命令中完成路徑時,請使用CM- /
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.