在vim中,您可以通过VI做到这一点”,六[,VI(...如何在Emacs中的引号,括号...之间选择文本?
例如,如果你有这样一行:
x = "difference between vim and emacs"
光标是那些之间的任何位置报价和你打六”,则该字符串会在视觉上 选择。
在vim中,您可以通过VI做到这一点”,六[,VI(...如何在Emacs中的引号,括号...之间选择文本?
例如,如果你有这样一行:
x = "difference between vim and emacs"
光标是那些之间的任何位置报价和你打六”,则该字符串会在视觉上 选择。
几乎所有模式的支持‘(,)’为p并且大多数还支持方括号“[,]”和大括号“{,}”。但是,你可以让任何 对字符的括号对,通过使用以下命令 :
(modify-syntax-entry ?^ "($")
(modify-syntax-entry ?$ ")^")
而且,看看这个帖子How to mark the text between the parentheses in Emacs?。每此篇
给定的密钥组合尝试密钥序列C-M-u C-M-SPC
(即,在保持Control
和Meta
键,按u
和在序列Space
),其执行这些命令backward-up-sexp
和mark-sexp
封装expand-region是方便为了这。调用er/expand-region
以引号内的点标记最近的单词,然后再次调用它将标记引号内的所有单词。 (第三次调用将扩大该区域以包含引号。)
我必须将它绑定到C-;
。
(global-set-key (kbd "C-;") 'er/expand-region)
通过这种结合,pressng C-; C-;
将突出引号之间的文本。
@qed如果您选择的文本是因为您想对其进行操作(复制它,杀死它等)还有[change-inner.el](https://github.com/magnars/change-inner.el),它是建立在'expand-region.el'之上的“给你vim的'ci'命令”。 – itsjeyd
在工具箱
https://launchpad.net/s-x-emacs-werkstatt/+download
的顶部以下键/命令传送:
(global-set-key [(super \))] 'ar-parentized-atpt)
(global-set-key [(super \])] 'ar-bracketed-atpt)
(global-set-key [(super \})] 'ar-braced-atpt)
(global-set-key [(super \")] 'ar-doublequoted-atpt)
(global-set-key [(super \')] 'ar-singlequoted-atpt)
这样与一对夫妇称为定界符将构成命令的更多字符的。
ar-delimited-atpt
将返回最近分隔符找到的点周围的字符串。
A组更强大的命令的允许重新使用的密钥那样
(global-set-key [(control c)(\")] 'ar-doublequote-or-copy-atpt)
(global-set-key [(control c)(\')] 'ar-singlequote-or-copy-atpt)
(global-set-key [(control c)(<)] 'ar-lesser-angle-or-copy-atpt)
(global-set-key [(control c)(>)] 'ar-greater-angle-or-copy-atpt)
这里一个doctring作为例子给出:
ar-doublequote-or-copy-atpt is an interactive Lisp function in
`thing-at-point-utils.el'.
It is bound to C-c ".
(ar-doublequote-or-copy-atpt &optional NO-DELIMITERS)
If region is highlighted, provide THING at point with doublequote(s),
otherwise copy doublequote(ed) at point.
With C-u, copy doublequote(ed) without delimiters.
With negative argument kill doublequote(ed) at point.
使用库thingatpt+.el和thing-cmds.el。
你会发现那里的命令,如thing-region
,它选择点的东西作为区域。由于string-contents
和list-contents
定义的东西(在thingatpt+.el
),这些选择串/列表内容的区域:
(thing-region "string-contents") ; Select the contents of the string at point.
(thing-region "list-contents") ; Select the contents of the list at point.
或交互:
M-x thing-region RET string-contents RET
其他相关命令包括:
C-M-U
(又名C-M-S-u
) - mark-enclosing-list
:选择封闭名单。重复以展开列表级别。适用于任何平衡括号表达式(例如向量):无论当前语法表定义为具有平衡分隔符语法。
mark-thing
- 选择给定类型的连续事物(重复)。
next-visible-thing
- 移动到给定类型的下一个可见事物(重复)。
密切相关:[如何标记Emacs中圆括号之间的文本?](http://stackoverflow.com/q/5194417/1199226) – itsjeyd