There is no (documented) option to hide line numbers in search results in files. To avoid copying line numbers, you must either carefully use multiple selections to copy all lines and skip numbers, or use search and replace, as Danil mentioned in his answer.
However, with a bit of plugin code, you can get the best of both worlds by creating a sublime heavy lift for you.
For example, select Tools > Developer > New Plugin... in the menu and replace the contents of the buffer with the following python code, then save it, for example. find_results_copy.py . It should be in your User package (the name does not matter, only the extension), but Sublime should take care of this automatically if you use the menu item to create a stub plug-in.
[edit] The plugin code has been modified to use a single regex operation, which (due to late night brain fart) was originally implemented using two operations. [/ Edit]
import sublime import sublime_plugin import re class FindResultsCopyCommand(sublime_plugin.ApplicationCommand): def run(self): sublime.active_window ().run_command ("copy") sublime.set_clipboard (re.sub (r"^\s*[0-9]+.", "", sublime.get_clipboard (), flags=re.MULTILINE))
This implements a new command called find_results_copy , which first runs the default copy command and then modifies the contents of the clipboard with regular replacement of the expression to throw away line numbers.
Now you can implement a special key binding to invoke this command. Since we want this command to invoke a search for results, you can reuse the standard keyboard shortcut, modified to use our new command and with an added context that forces it to take effect only to search for results.
This example uses the keyboard command for Windows / Linux; if you use a Mac instead of super+c to match the standard key for this platform.
{"keys": ["ctrl+c"], "command": "find_results_copy", "context": [ { "key": "selector", "operator": "equal", "operand": "text.find-in-files", "match_all": true }, ] },
Since this uses the default copy command, if you copy_with_empty_selection , it will copy the current line without a line number if you do not select anything if you are used to working this way.
If you wish, you can also duplicate this command (you can save it in the same file) and rename the class to FindResultsCutCommand and execute the cut (with the appropriate key binding) to also be able to cut the text and delete line numbers if you need to.