ipython icon indicating copy to clipboard operation
ipython copied to clipboard

Comment/uncomment selection in notebook

Open piti118 opened this issue 14 years ago • 22 comments

I think this would be a nice addition.

a = 1
<start selection>
print some debug information
print some other that i do not want any more
<end selection>
b =2 

I know the shortcut like ctrl+/ would be hard to implement cross platform. But for simple case that's often used, when we select a block of code(say more than 1 line) and press "#" it should do comment/uncomment those lines (like a block tab). This would cover the cases where this type of thing is most useful.

piti118 avatar Mar 31 '12 20:03 piti118

We definitely want to have this.

ellisonbg avatar Apr 12 '12 19:04 ellisonbg

I'm not sure if bfbe5a8f4c43444a1b2b83c8ea71fac320bfe872 is already part of a release, but ctrl+/ (german key layout means that it's actually ctrl+7 or ctrl+shift+7) or selction+<#> don't work in my notebook. It would also be nice if such things (i.e < tab > as well! For me code compeltition was ctrl+space) could be documented in the shortcut help.

It would also be nice if such an action could be added to a icon...

jankatins avatar Jan 06 '13 11:01 jankatins

Agree, we want this for sure. While in 1.0dev I still don't see this functionality, let us hope it will be implemented in 1.0.

magican avatar Jun 14 '13 09:06 magican

This is now a codemirror addon but one should decide wether or not we bind a key shortcut to it, or only a menu entry...

Carreau avatar Jul 05 '13 14:07 Carreau

I think it would be great to have a key binding for this...

ellisonbg avatar Jul 05 '13 18:07 ellisonbg

standard binding is C-/, any objection?

minrk avatar Jul 05 '13 18:07 minrk

C-/need shift on some keyboard...just saying

Carreau avatar Jul 05 '13 18:07 Carreau

I am fine with ctrl-/, but let's also include command on mac...

On Fri, Jul 5, 2013 at 11:38 AM, Matthias Bussonnier < [email protected]> wrote:

C-/need shift on some keyboard...just saying

— Reply to this email directly or view it on GitHubhttps://github.com/ipython/ipython/issues/1540#issuecomment-20533204 .

Brian E. Granger Cal Poly State University, San Luis Obispo [email protected] and [email protected]

ellisonbg avatar Jul 05 '13 18:07 ellisonbg

we could also wait for the refactoring of the keybindings....

Carreau avatar Jul 05 '13 18:07 Carreau

Yes, I generally mean C=ctrl one others, command on OS X for shortcuts.

minrk avatar Jul 05 '13 18:07 minrk

sure, I'll hold off.

minrk avatar Jul 05 '13 18:07 minrk

I think the hotkey stuff is a mess (not IPython's fault). Could you elaborate on the refactoring of the keybindings ?

For my personal use, I have created a few notebook extensions with my favourite hotkeys for Firefox: https://github.com/juhasch/IPython-nb-extensions

Unfortunately, it needs patching of IPython, to notify the extension when new codecells are added. It then extends the codemirror hotkeys using setOption().

Anyway, for me commenting/uncommenting works, but not too well. It gets confused by my coding style. Codefolding can be easily added this way, too. I did not find it too useful for now.

juhasch avatar Jul 05 '13 19:07 juhasch

For 1.0 we are changing the notebook to be a dual mode editor like VIM...The keyboard shortcuts in the notebook command mode will possibly extensible and configurable. The keyboard shortcuts in edit mode and for mode changes won't be allowed to change.

On Fri, Jul 5, 2013 at 12:00 PM, juhasch [email protected] wrote:

I think the hotkey stuff is a mess (not IPython's fault). Could you elaborate on the refactoring of the keybindings ?

For my personal use, I have created a few notebook extensions with my favourite hotkeys for Firefox: https://github.com/juhasch/IPython-nb-extensions

Unfortunately, it needs patching of IPython, to notify the extension when new codecells are added. It then extends the codemirror hotkeys using setOption().

Anyway, for me commenting/uncommenting works, but not too well. It gets confused by my coding style. Codefolding can be easily added this way, too. I did not find it too useful for now.

— Reply to this email directly or view it on GitHubhttps://github.com/ipython/ipython/issues/1540#issuecomment-20534088 .

Brian E. Granger Cal Poly State University, San Luis Obispo [email protected] and [email protected]

ellisonbg avatar Jul 05 '13 19:07 ellisonbg

That's a big change for a release scheduled for ten days from now.​ We should have flipped the 'no new features' switch a month ago. Like the other big-ish recent changes, this is a 'hopefully', not a 'definitely' 1.0 change.

minrk avatar Jul 05 '13 19:07 minrk

Agreed with @minrk I though we said vim/emacs mode will be only through custom.js if doable for 1.0

Carreau avatar Jul 05 '13 19:07 Carreau

Sorry, I wasn't clear - at best I might be able to get the vim/emacs mode working through custom.js for 1.0.

On Fri, Jul 5, 2013 at 12:22 PM, Matthias Bussonnier < [email protected]> wrote:

Agreed with @minrk https://github.com/minrk I though we said vim/emacs mode will be only through custom.js if doable for 1.0

— Reply to this email directly or view it on GitHubhttps://github.com/ipython/ipython/issues/1540#issuecomment-20534992 .

Brian E. Granger Cal Poly State University, San Luis Obispo [email protected] and [email protected]

ellisonbg avatar Jul 05 '13 20:07 ellisonbg

Aside: for publicity, I think we should come up with a more appealing way to describe the new interaction than 'a dual mode editor like VIM'. There's nothing wrong with VIM, but I don't think being like VIM is the best selling point for our target audience.

On 5 July 2013 21:15, Brian E. Granger [email protected] wrote:

Sorry, I wasn't clear - at best I might be able to get the vim/emacs mode working through custom.js for 1.0.

On Fri, Jul 5, 2013 at 12:22 PM, Matthias Bussonnier < [email protected]> wrote:

Agreed with @minrk https://github.com/minrk I though we said vim/emacs mode will be only through custom.js if doable for 1.0

— Reply to this email directly or view it on GitHub< https://github.com/ipython/ipython/issues/1540#issuecomment-20534992> .

Brian E. Granger Cal Poly State University, San Luis Obispo [email protected] and [email protected]

— Reply to this email directly or view it on GitHubhttps://github.com/ipython/ipython/issues/1540#issuecomment-20537071 .

takluyver avatar Jul 05 '13 21:07 takluyver

Agreed with @takluyver, despite being a vim addict myself. How about just "modal editor". Emacs also has the concept of modes - the same shortcuts have different meaning depending on which mode one is in

ivanov avatar Jul 05 '13 21:07 ivanov

The dual-mode that we are considering is actually closest to that of Gmail / Greader, etc. (which, of course, is derived from vim but is a bit more friendly as a reference).

minrk avatar Jul 05 '13 21:07 minrk

I'd introduce it as something like "you can now navigate cell-by-cell with the keyboard, then hit enter to edit the current cell". Then refer to the modes as 'navigating' and 'editing'.

On 5 July 2013 22:20, Min RK [email protected] wrote:

The dual-mode that we are considering is actually closest to that of Gmail / Greader, etc. (which, of course, is derived from vim but is a bit more friendly as a reference).

— Reply to this email directly or view it on GitHubhttps://github.com/ipython/ipython/issues/1540#issuecomment-20539498 .

takluyver avatar Jul 05 '13 21:07 takluyver