Open gapplef opened 5 years ago
So, is there any way to end a code cell without start a new cell below it?
No, there isn't and I don't know how we could do it without making things confusing for users.
If you have a good proposal and are willing to implement it (because I don't see a good use case for it), then I'm all ears.
@ccordoba12 I'm an ordinary user that do scientific computing with python, may not able to implement the feature.
The user case is highlighting some specific code blocks, and/or description the function or purpose of the code blocks, while have no influence on other lines of the source code (current code cell can't avoid this, and can be very annoying when using within the body of def
.).
One possible proposal is use different indicator for start and end of code cell. like #<start cell>, #<end cell>
or #<<, #>>
@bcolsen, what do you think about @gapplef's proposal?
@gapplef is this idea just for highlighting the code or is it for code execution in the console?
Generally a section of code in the middle of a function wouldn't execute on it's own in the console due to the differing namespaces, so I don't see much point for code execution inside function definitions. I think that combining this with the current code cells would be confusing and would have many parsing corner cases. So I guess I'm :-1: on start and end point for the current code cells.
Now for the highlighting sections of code for other users or yourself to see or change, that could have a use. This is where we would see the use of things like block comment headers and TODO tags being used. I could, for example highlight, a section of code for another user to change or only change this part. I think the new bookmark implementation could cover some of the use cases here. I wouldn't be opposed to some one adding something like this, but I also don't think the need is that great.
Closing due to lack of response.
@bcolsen mainly for highlighting the code, not for code execution in the console, like I said:
highlighting some specific code blocks, and/or description the function or purpose of the code blocks, while have no influence on other lines of the source code.
I mainly want to make my long function easier to understand. Like you said, may not a good choice to mix up with current code cell.
I'll reopen this and change the title to "Add a way to highlight sections of code with the syntax highlighter".
This will be a low priority in the project and will need a community volunteer to implement it.
I agree with @bcolsen and I don't know how it could be done without interfering with our cell functionality.
Problem Description
code cell
is very neat feature of Spyder. A code cell is just a code block that separate with line start with#%%
. I can start a code cell with a line leading with#%%
, and end that cell with another line leading with#%%
. But that will start a new code cell below that line automatically(and also a new code cell before the first line leading with#%%
).I would like to highlight some specific lines of code with code cell. For instance, several lines of code in a function may have special purpose, while the lines before and after it just ordinary code. So, is there any way to end a code cell without start a new cell below it? Like start a cell with a line leading with
#<<
, while end a cell with a line leading with#>>
.Versions