Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not unfold a pasted folded section in sublimetext #494

Open
luisalvarado opened this issue Sep 26, 2014 · 4 comments
Open

Do not unfold a pasted folded section in sublimetext #494

luisalvarado opened this issue Sep 26, 2014 · 4 comments

Comments

@luisalvarado
Copy link

I am working with a 4+ MB file and many sections in it are folded. I want to copy some sections and paste them somewhere else in the file without them unfolding themselves whenever I paste.

The example is easy:

Fold some code and copy the folded line

Paste anywhere else and it will unfold automatically.

I need for sublime to not unfold the code, if it is unfolded then leave it unfolded. If it is folded, then leave it folded. The same should apply not only from copying and pasting but also remembering or setting the state of an unfold / folded part when opening and saving the file. This would REALLY help when working with huge files since, with sublime, I do not even use gedit, kate or others when dealing with huge files. sublime is enough.

This is part of a question asked in StackOverflow: http://stackoverflow.com/questions/26050795/do-not-unfold-a-pasted-folded-section-in-sublimetext

@FichteFoll
Copy link
Collaborator

Currently ST just expands folded regions when copying so that the entire text is put into the clipboard, and when pasting it just pastes that text. In order to do this, I think the best way would be to save some metadata, specifically the folded region(s) in the selection, to a different clipboard field. I don't know how clipboards work cross-platform though.

If you can access custom fields of the clipboard from python, this would be possible to implement as a plugin that overrides the copy, cut and paste commands.

Edit: Okay, it would be possible on Windows using the ctypes module. Don't know about UNIX. If that doesn't work, I feel like you need to save the clipboard's contents locally and compare against them when a paste command is triggered.

@luisalvarado
Copy link
Author

Thanks FichteFoll. This would be an interesting option to have for specific cases like this where I use sublime as some category/classification system and can fold/unfold they informacion I want to work on. Would be pretty neat, especially when working with 600+ folded sections currently.

@ghost
Copy link

ghost commented Jul 8, 2015

also remembering or setting the state of an unfold / folded part when opening and saving the file

This alone would save a lot of trouble and having to use BufferScroll just for this functionality.

@luisFebro
Copy link

A workaround for that is to copy normally your files into the destination´s project folder and then select all your recently pasted files and hit ctrl+K and then 1 in order to fold all your unfolded archives. If you wish to unfold all quickly, there is a sublime shortcut pattern as well: ctrl+K and then J. As you may know, you can customize your shortcuts in settings for better options of them. In a web creation it is very helpful to me to copy and paste page patterns with my folded codes. Hope you will find it helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants