开发者

isearch across line breaks

Is it possible to make isearch disregard line breaks, i.e. a search for foo bar will find

.......... foo
bar .....

I get bitten by isearch failing on such queries regularly when navigating long documents, and it's rather annoying. I am aware that word-search-forward finds matches across lines, but it has certain shortcomings (e.g. it forces you to use complete words, so a search for "foo b" will fail; it doesn't highlight search results), and, more importantly, it's a little silly to use a different command depending on whether you are searching for on开发者_运维技巧e word or two.


Use C-M-s - isearch-forward-regexp. This will interpret space characters as a marker for any white space character.


As prompted by @Teddy, here’s my comment in answer form.

In order to obtain the desired behaviour, I did not have to customise isearch-forward-regexp, but simply customise search-whitespace-regexp to [ \t\r\n]+as suggested in the documentation. This way you can then use search-forward as usual.


In a recent enough emacs, isearch-forward-word, which is bound to M-s w, is a simpler solution: there is no need for any configuration of search-whitespace-regexp.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜