改变Emacs前进行为 [英] Changing Emacs Forward-Word Behaviour
问题描述
我的$ abs_target_path [] = abs_path($ target);
< M-f>
我的$ abs_target_path = abs [_] path($ target);
我知道我可以使用Mf Mb,但就我而言,不应该有必要,我想改变它。特别是,我想要两件事:
- 当我按Mf时,我想去下一个字的第一个字符,无论是否该点在一个单词内,一组空格或其他地方。
- 逐个模式地自定义字符。毕竟,在CPerl模式下移动不同于TeX模式。
所以,在上面的例子中,项目1将在点击Mf后,光标将移动到a(并指向左侧)。项目2将允许我将下划线和标语定义为字符。
尝试:
(require'misc)
然后使用 Mx转发单词
,看看它是否执行你想要的。然后,您可以重新绑定 Mf
等。
要使 _
不是一个单词分隔符(即使它成为一个单词成分)C& C ++模式,你可以这样做:
(modify-syntax-entry?_wc-mode-syntax-table )
(modify-syntax-entry?_wc ++ - mode-syntax-table)
有关语法表的更多信息,请阅读此维基页面。语法表通常命名为 tex-mode-syntax-table
和 cperl-mode-syntax-table
。 p>
As the title says, how does one change the behaviour of emacs forward-word function? For example, suppose [] is the cursor. Then:
my $abs_target_path[]= abs_path($target);
<M-f>
my $abs_target_path = abs[_]path($target);
I know I could just use M-f M-b but as far as I'm concerned, that shouldn't be necessary and I'd like to change it. In particular, I want two things:
- When I press M-f, I want to go to the first character of the next word regardless of whether the point is within a word, within a group of spaces or somewhere else.
- Customize word-characters on a mode-by-mode basis. After all, moving around in CPerl mode is different than, say, TeX mode.
So, in the above example, item 1 would have the cursor would move to the 'a' (and the point to it's left) after hitting M-f. Item 2 would allow me to define underscores and sigils as word characters.
Try:
(require 'misc)
Then use M-x forward-to-word
and see if it does what you want. You can then rebind M-f
, etc.
To make the _
not a word separator (i.e. make it a word constituent) for C & C++ mode, you would do this:
(modify-syntax-entry ?_ "w" c-mode-syntax-table)
(modify-syntax-entry ?_ "w" c++-mode-syntax-table)
For more information on syntax tables, read this wiki page. Syntax tables are generally named like tex-mode-syntax-table
and cperl-mode-syntax-table
.
这篇关于改变Emacs前进行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!