emacs abbrev-mode

    技术2025-09-11  7

    默认情况下该模式是不开启的,要开启可以用 M-x abbrev-mode

     

    定义缩写也是分全局和局部的

    ThisIsAFuncionName  光标置于该单词之后,C-x a g  再输入a 当再输入a的时候 C-x a e就会看到a扩展成为前面那个长单词了。

    C-x a l 与mode有关的abbrev.

    C-x a g ==>add-global-abbrev

    C-x a l ==> add-mode-abbrev

    上面两个是先给出被缩写的然后再给缩写的。先给ThisIsAFuncionName  再给a.

    还有两个函数没有快捷键但是感觉比上面的方便些:

    define-global-abbrev

    define-mode-abbrev

    要先输入缩写的名字然后再给具体的缩写。感觉比较方便。

    技巧:

    把你想要扩展的文字放在一个buffer的开头,多次按下C-u,然后再C-x a g,便可以为整个你想扩展的文字添加扩展。

    可以用edit-abbrev命令来修改现有的abbrev。

    这是.emacs中的配置:

    ;abbrev-mode ;Abbrev-mode always open (setq default-abbrev-mode t) (setq abbrev-file-name ;; tell emacs where to read abbrev "~/.emacs.d/abbrev_defs") ;; definitions from... (setq save-abbrevs t) ;; save abbrevs when files are saved ;; you will be asked before the abbreviations are saved (quietly-read-abbrev-file) ;; reads the abbreviations file on startup ;Avoid errors if the abbrev-file is missing (if (file-exists-p abbrev-file-name) (quietly-read-abbrev-file))

    最新回复(0)