
我一直在使用 emacs 進行 C 編程,現在我想編寫一些 Assmebly 程式碼,當我按 Tab 時,emacs 只是插入空格。如何強制它使用 Tab 鍵識別目前行?
答案1
嘗試氣體模式而不是內建的 asm 模式。
答案2
使用el-patch
:
(el-patch-defun asm-calculate-indentation ()
(or
;; Flush labels to the left margin.
(and (looking-at "\\(\\sw\\|\\s_\\)+:") 0)
;; Same thing for `;;;' comments.
(and (looking-at "\\s<\\s<\\s<") 0)
(el-patch-remove
;; Simple `;' comments go to the comment-column.
(and (looking-at "\\s<\\(\\S<\\|\\'\\)") comment-column))
;; The rest goes at the first tab stop.
(or (indent-next-tab-stop 0))))
(defun my--indent-asm-setup ()
"Set up indentation variables.
Indent with tabs, and make the TAB key behave like it's supposed
to."
(setq-local indent-tabs-mode t)
(setq-local tab-always-indent (default-value 'tab-always-indent)))
(add-hook 'asm-mode-hook #'my--indent-asm-setup)
答案3
就這樣吧。大多數編輯器都可以選擇將製表符轉換為空格。為什麼您希望編輯器將製表符轉換為空格?您可以獲取程式碼(以保存的檔案形式或複製到剪貼簿)並在任何編輯器中使用它,它看起來是一樣的。如果您強制它使用選項卡,並將其貼上到此處,或者(我們)在編輯器中打開它,它很可能看起來像垃圾,因為我們可能將選項卡設定為特定大小。
如果您確實必須使用製表符而不是空格,請幫我們一個忙,將製表符轉換為空格,然後再在此處發布或將其提供給其他人。