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

Recognize and run code blocks #13

Open
ngharrison opened this issue Apr 25, 2020 · 6 comments
Open

Recognize and run code blocks #13

ngharrison opened this issue Apr 25, 2020 · 6 comments

Comments

@ngharrison
Copy link

Just a feature suggestion. The ability to run blocks of code delimited by %% would be very useful. Thanks for the great extension!

@apommel
Copy link
Owner

apommel commented Apr 26, 2020

Thanks for your feedback! You mean that this feature would be able to run blocks one after the other, a bit like Jupyter?

@ngharrison
Copy link
Author

Yes, similar to that. The idea of code blocks or code cells. The Matlab IDE does this itself using %%.
There is similar functionality in Python IDEs (Jupyter, Spyder, VSCode Python extension) with some delimiter such as #%%.

One more thing I'd add on is to have the focus stay in the editor when code (selection, line, block, etc.) is run. Currently it always takes me to the terminal and I have to click back into the editor to run the next line.

These would be nice features. I'm not sure how complicated they would be.

@aidedinertial
Copy link

Here is my workaround for cell evaluation:

This solution requires the Vim extension.

  1. Press Escape to enter Vim Command Mode
  2. Type /%% to search for the beginning of a cell
  3. Type N to find the top of the current cell (or g to jump to beginning of file)
  4. Type Shift+V to select the current line
  5. Type n to jump to beginning of next cell (or G to jump to end of file)
  6. Use mapped keybinding to run command "extension.runMatlabSelection"

I have also mapped <Ctrl+A> to toggle focus between the editor and terminal.

@weihongliang233
Copy link
Contributor

Yes, similar to that. The idea of code blocks or code cells. The Matlab IDE does this itself using %%.
There is similar functionality in Python IDEs (Jupyter, Spyder, VSCode Python extension) with some delimiter such as #%%.

One more thing I'd add on is to have the focus stay in the editor when code (selection, line, block, etc.) is run. Currently it always takes me to the terminal and I have to click back into the editor to run the next line.

These would be nice features. I'm not sure how complicated they would be.

Check out this issue/pullrequest Adding "Cursor Back to Editor" function for "Run Current Selection". It solves your second problem.

@weihongliang233
Copy link
Contributor

I think "splitting code into blocks" should be an independent functionality. I'm working on it. Here is a demo. I'll integrate it into this extension soon and hope can implement the "run code blocks" functionality.

@weihongliang233
Copy link
Contributor

Almost done (if there is no unexpected bugs).

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

No branches or pull requests

4 participants