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

feat: copy code blocks #156

Closed
wants to merge 1 commit into from
Closed

feat: copy code blocks #156

wants to merge 1 commit into from

Conversation

mellonnen
Copy link
Contributor

Changes Introduced

  • c will copy code blocks to clipboard.

Currently, all blocks are copied individually in order. So the last code block will be on top of the "clipboard stack" if you use a clipboard manager. You could concatenate all blocks and copy them to the clipboard as a single entry.

Or, you could have slightly nicer behavior by having c copy a single block and then maintain a counter that tracks which block should be copied next and then have C concatenate all blocks into a single clipboard entry.

@maaslalani
Copy link
Owner

Hey! Thanks for the contribution, I haven't noticed many people ask for this feature. Curious if you have needed it in the past for your own presentations. The reason I am asking is I am trying to avoid adding too many unnecessary features that might go unused and increase the possibilities of bugs and maintenance.
That being said this feature seems very reasonable so if you have a compelling use case for it I wouldn't be opposed to adding it. And, thank you for submitting a great PR :)

@mellonnen
Copy link
Contributor Author

I had to do a live demo presentation and had to do some live programming. To make it easier for me I could prepare the code snippets as code blocks in slides . This allowed me to copy the code blocks easily and switch back to my editor, which was quite nice. This scenario may be quite niche but it made the presentation very smooth, and some audience members asked about slides afterward and specifically this feature.

However, as the code blocks are parsed for the purpose of being executed I could not simply have an "incomplete" go snippet as it would not compile. I was able to "solve" it by annotating each go code block as js as there is no type checking etc. This in combination with the scenario of multiple code blocks kind of makes feature kinda wonky tbh 😅.

@maaslalani
Copy link
Owner

Ah I see, regarding the incomplete code snippets, I really want to implement #135 which would solve that problem and make a smooth experience for executing code and having compiling code :)

And, if I'm reading this correctly would make it so that you don't need to switch back to your editor to see if the code compiles?

@mellonnen
Copy link
Contributor Author

And, if I'm reading this correctly would make it so that you don't need to switch back to your editor to see if the code compiles?

Not really, I used the presentation more like a cheat sheet, so the purpose was to switch to the editor and paste the snippet into a code base instead of live coding it. Here is the repo for the presentation if that helps you understand.

The issue was that slides would throw an error as the snippet was not a valid go program. However, I can't seem to reproduce it now... so maybe there was something else that was the issue. It was about a month ago so I do not really remember.

@maaslalani
Copy link
Owner

Ah I see what you mean. I'm going to make some changes to this PR (change the keybinding to alt+c) and will merge it

@maaslalani
Copy link
Owner

#173 y for yanking code blocks :)

@maaslalani maaslalani closed this Jul 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants