You select folded text and copy-paste it. Is there any way to keep text folded, so it does not expand when you paste it.
Paste folded text
pu239
#2
I would like this as well, sometimes when trying to bring related functions closer I collapse all at some indent level and then want to just move around a whole folded thing while not expanding it afterwards.
Currently though I don’t think there is a workaround for it.
0 Likes
IGRACH
#3
I’m using this plugin:
import sublime
import sublime_plugin
class PasteAndReindentCommand(sublime_plugin.TextCommand):
def run(self, edit):
before_selections = [sel for sel in self.view.sel()]
self.view.run_command('paste')
after_selections = [sel for sel in self.view.sel()]
new_selections = list()
delta = 0
for before, after in zip(before_selections, after_selections):
new = sublime.Region(before.begin() + delta, after.end())
delta = after.end() - before.end()
new_selections.append(new)
self.view.sel().clear()
self.view.sel().add_all(new_selections)
self.view.run_command('reindent')
This was originally posted on this forum, but I can’t find the original post.
I bind this to ctrl+shift+v
and text is selected when it’s pasted. Then you just need to fold it again.
But it would be nice to do that in one step xD
0 Likes
OdatNurd
#4
If that command pastes the way you want and leave selected text that you would like to be folded, try adding this line to the bottom of it:
self.view.run_command("fold")
1 Like