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

Evaluate current line (and move to next line) or selection #128

Open
ghost opened this issue May 13, 2018 · 5 comments
Open

Evaluate current line (and move to next line) or selection #128

ghost opened this issue May 13, 2018 · 5 comments

Comments

@ghost
Copy link

ghost commented May 13, 2018

Thank you for the beautiful MEP tool.

I wonder if we can have the following two features:

  1. Evaluate current line or section.
    If no selection, evaluate the current line (also see the Feature 2 below). If a line or part of a line (e.g., a variable, etc) is selected, only evaluate the selection.

  2. Evaluate current line and move to the next line
    Currently, the SHIFT+F9 will select the current line and execute it. After executing, the line remains selected.
    Is there a way to set it to move the mouse cursor to the next uncommented line? This is a really convenient feature in RStudio.

The following post has a solution to this. However, it does not provide a way to customize the shortcut key. I replaced the shortcut key (SHIFT+F9) to F4. One key is easier to handle than two keys.

https://www.mathworks.com/matlabcentral/answers/132119-keyboard-shortcut-to-evaluate-current-line

Thanks.

@ghost ghost changed the title Run current line and move to next line Evaluate current line (and move to next line) or selection May 14, 2018
@MartinLechner-TD
Copy link
Contributor

I think I would be the best to search for the next 'uncommented line' to check if the line starts (excluding whitespaces) with the % character. I propose this because I often use block comment (%{ ... %}) to add some usage examples to the functions help section. For the evaluation of these examples I am in commented lines but they doesn't begin with a % character.
The feature to execute the current line without moving to the next line was introduced to quickly test the current line or lines in functions or methods. Therefore, I would suggest keeping the current function and introduce the new function with a new shortcut (e.g. CTRL+F9).

@GavriYashar
Copy link
Owner

@cowlumbus

  1. Evaluate current line or section. [...] only evaluate the selection.

Isn't this the behavior of F9?

  1. Evaluate current line and move to the next line [...]

This is definitely an improvement.

@MartinLechner-TD
I could check whether the SHIFT + F9 was called inside an block comment. if so jump to next line inside block comment. otherwise skip block comments.

@ghost
Copy link
Author

ghost commented May 22, 2018

@GavriYashar
Evaluate current line or section. [...] only evaluate the selection.
Isn't this the behavior of F9?

F9 only runs if a chunk of code (either a variable, a section of a line, a line, or multiple lines) is selected. I like your function of run the current line without selecting it. Now I want to know if we can combine these two functions into one hotkey like what RStudio does. Thanks.

@GavriYashar
Copy link
Owner

GavriYashar commented May 22, 2018

oh... haven't thought of that. should be possible.
I'll consider making it an option to let users choose which one they prefer. This would allow users to backup if Matlab doesn't behave as it should after MEP is installed.

@GavriYashar
Copy link
Owner

GavriYashar commented Nov 5, 2018

  • Jump to next line that is not a comment
  • Block comments are ignored if outside of block comment
  • empty lines are ignored
  • if nothing is selected select whole line, if something is selected just evaluate selection (iirc)

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

2 participants