在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