In Sublime when you have nothing selected and click ctrl+c
you will copy whole line with the new line. How to remove that new line, so ctrl+c
will copy only current line.
I’m using Sublime on Windows.
In Sublime when you have nothing selected and click ctrl+c
you will copy whole line with the new line. How to remove that new line, so ctrl+c
will copy only current line.
I’m using Sublime on Windows.
A naive attempt:
import sublime
import sublime_plugin
class CopyWithoutNewlineCommand(sublime_plugin.TextCommand):
def run(self, _: sublime.Edit) -> None:
if self.view.has_non_empty_selection_region():
self.view.run_command('copy')
return
sublime.set_clipboard(
"\n".join(
self.view.substr(self.view.line(region))
for region in self.view.sel()
)
)