我正在使用 Sublime Text 中的“查找全部”功能,我想从查找结果中再看到几行。我找不到这个设置——有什么办法吗?
3 回答
To expand upon DarkWater's comment to your question:
Add new lines with a regex before and after your search string:
.*\n.*\n.*search_string.*\n.*\n.*
This will match 2 new lines before and after your search_string
.
Make sure you enable regular expression searching in the find dialog. Also make sure that you escape any regex special characters in your search_string
.
To expand on the solutions provided by @dasl and @zaboco
I found that this variation was more suitable.
Example:
(.*\n){0,2}.*search_string.*(\n.*){0,2}
This will match 0-2 new lines before/after your search_string. Adjust numbers as needed to provide more/less context, but always keep the 0 as the first number in the quantifier.
Again, make sure you enable regular expression searching in the find dialog.
(The original regexes required that 2 lines above/below are present in the files, and excluded some necessary files from the search results)