改变 Emacs 转发行为 [英] Changing Emacs Forward-Word Behaviour

查看:21
本文介绍了改变 Emacs 转发行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所说,如何改变 emacs forward-word 函数的行为?例如,假设 [] 是光标.然后:

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);

我知道我可以只使用 M-f M-b 但就我而言,这应该没有必要,我想更改它.特别是,我想要两件事:

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:

  1. 当我按 M-f 时,我想转到下一个单词的第一个字符,无论该点是在一个单词内、一组空格内还是其他地方.
  2. 逐个模式自定义单词字符.毕竟,在 CPerl 模式下移动不同于 TeX 模式.

因此,在上面的示例中,项目 1 将使光标在点击 M-f 后移动到 'a'(及其左侧的点).第 2 项允许我将下划线和符号定义为单词字符.

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.

推荐答案

尝试:

(require 'misc)

然后使用 M-x forward-to-word 看看它是否符合您的要求.然后你可以重新绑定M-f

Then use M-x forward-to-word and see if it does what you want. You can then rebind M-f, etc.

为了使 _ 不是 C & 的单词分隔符(即使其成为单词组成部分)C++ 模式,你会这样做:

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)

有关语法表的更多信息,请阅读此维基页面.语法表通常命名为tex-mode-syntax-tablecperl-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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆