簡體   English   中英

EMACS和TAB鍵(縮進vs \\ t插入)

[英]EMACS and TAB key (indent vs \t insert)

假設我有一個<weird language>文件,我正在編輯它。

如果光標位於句子的開頭(假設一個if ,已經縮進了2個級別),並且我按了TAB ,那么我希望EMACS可以增加該行的縮進級別+1(使用TABN SPACEs ,具體取決於文件中使用的縮進樣式)。

無論如何,如果我按下TAB並且光標位於if之后, if我希望EMACS插入一個普通\\t

如何使EMACS表現得像這樣?

問候

將當前縮進作為開始。 該條件可能需要修改。 另請參閱第三條款。

(defun my-indent-or-insert-tab ()
  "Insert a TAB or indent depending on context. "
  (interactive "*")
  (cond((eq (current-column) (current-indentation)) 
        (indent-for-tab-command))
       ((member (char-after) (list ?\t ? ?\n))
        (insert "\t"))
       (t (message "%s" "Don't know what to do if inside word"))))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM