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

Added shorcuts to split cell, merge cell above and merge cell below. #3571

Merged
merged 2 commits into from Jul 15, 2013
Merged

Added shorcuts to split cell, merge cell above and merge cell below. #3571

merged 2 commits into from Jul 15, 2013

Conversation

damianavila
Copy link
Member

OK, I think that we desperately need a shortcut key to split cell function... and also it would be great to have the same for merge cell above and merge cell below.

The task of splitting cell is a common task when you write documents containing a lot of text... or when you are doing a presentation using slideshow preset in the CellToolBar. The same, although with a less frequency, happens with merge cell functions... but yet I think they deserve a shortcut.

This PR implements this key events, and I have assigned the following keys (available in a row):

  • Ctrl-m 7 --- split cell
  • Ctrl-m 8 --- merge cell above
  • Ctrl-m 9 --- merge cell below

That's all...

Damián

pinging @ivanov who agreed with me in the SciPy sprint about the split shortcut... hehe... 👍

UPDATE: For now, we are only considering the split shortcut as Ctrl-m -

@minrk
Copy link
Member

minrk commented Jul 6, 2013

numbers are already assigned to heading cell levels, so probably not the best choice.

@damianavila
Copy link
Member Author

cell levels 1-6... 7, 8, 9 are free... but i don't have problem to change them... but...if not IPython shortcuts, the others keys are used by the browsers... so if not the numbers keys, what keys do you recommend?

@minrk
Copy link
Member

minrk commented Jul 6, 2013

pinging @ellisonbg for review on this one.

@ellisonbg
Copy link
Member

I agree we need keyboard shortcuts, but I think the numbers are bad choices. What letter are free?

@damianavila
Copy link
Member Author

I think we have almost all the letters covered... at least using Ctrl-m...
q is free (i don't know if some browsers use it, at least Chromium don't),
w-e-r-u-f-g are used by almost all the browsers,
and the rest of the letters are used by IPython.
Maybe using some symbols... if we want to keep Ctrl-m... or change to Alt or Shift, but It will be better I think to keep Ctrl-m...

@Carreau
Copy link
Member

Carreau commented Jul 7, 2013

I would tend to think that split and merge are not that important, and that we better have fix the hard coded keyboard shortcut than piling up shortcut. especially if we want dual-mode editor, we could free up shortcut later.

@damianavila
Copy link
Member Author

Hi, @Carreau... I fundamentally disagree with you in that ;-)
Maybe is a bias in my way to use the notebook, but I think a lot of people will find very very useful to have the split/merge functions linking to keyboard events because is a very recurrent event in the workflow of writing, editing and formatting a ipynb.
I don't know what is the current status of the dual-mode editor... we talked about getting it ready for 1.0, but I don't know how advanced is @ellisonbg in this modification... if the dual-mode is ready for 1.0, we can for sure wait for this and make what you suggested, but if it is not ready for 1.0, I think would be appropriate to have the shortcut for split/merge done in the current status of hard coded keyboard shortcuts.
I mean, hard-coded or after dual-mode, I think the the split/merge functions need shortcuts for the 1.0 release.

@takluyver
Copy link
Member

I'm pretty sure that the intention is to have the new editing system in
place before 1.0 - that's why we were focussing so much on it in the sprint.

@ellisonbg
Copy link
Member

I am making good progress on the dual mode work. I should have a PR ready this week. That the request, however, wont change that the number of available keyboard shortcuts.

Sent from my iPhone

On Jul 7, 2013, at 5:59 AM, Thomas Kluyver notifications@github.com wrote:

I'm pretty sure that the intention is to have the new editing system in
place before 1.0 - that's why we were focussing so much on it in the sprint.

Reply to this email directly or view it on GitHub.

@damianavila
Copy link
Member Author

Ok @ellisonbg, if your PR is not going to free some keyboard shortcuts, we have to deal with the decision to add or not add the shortcuts for this split/merge functions... I believe we have to add them...

@takluyver
Copy link
Member

That change won't make any more shortcuts available while editing, but it
will while navigating, because keystrokes won't be captured by the editor
then. Merge above/below could easily be done while navigating, but split
needs to be done while editing, because it hinges on the cursor position.

On 7 July 2013 17:23, Damián Avila notifications@github.com wrote:

Ok @ellisonbg https://github.com/ellisonbg, if your PR is not going to
free some keyboard shortcuts, we have to deal with the decision to add or
not add the shortcuts for this split/merge funcions... I believe we have to
add them...


Reply to this email directly or view it on GitHubhttps://github.com//pull/3571#issuecomment-20573108
.

@damianavila
Copy link
Member Author

I agree with you but... we will use the same keyboard shortcuts to do different things depending of the context?
Maybe, it sounds strange to me because I use IPython and a plain text editor to code...
This multiple behavior is common in vim or emacs?
From a pedagogical perspective, this can be very confusing for users not used to deal with advanced coding tools, like me... hehe

@takluyver
Copy link
Member

I wouldn't think of it as doing different things depending on context.
Rather, I think there will be certain things that you can only do while not
editing a cell. This isn't unusual: e.g. in GMail, I can normally type 'c'
to start composing a new e-mail. But if I'm already writing an e-mail,
typing 'c' just adds a c in the message. I guess we'll add some similar
single-key shortcuts which only apply when you're not entering text.

For reference, the 'dual-mode' behaviour (I'm trying to avoid calling it
that) is characteristic of vim, though apparently Emacs also has something
similar.

@damianavila
Copy link
Member Author

OK, thanks for explaining... but if this is the case, then we have the problem of lack of enough keys again... ;-)

@ivanov
Copy link
Member

ivanov commented Jul 9, 2013

for the record, though I do think we need a keyboard shortcut for splitting cells, Ctrl-m 7 was not what I had in mind ;)

@minrk
Copy link
Member

minrk commented Jul 9, 2013

Is Ctrl-M - available for split (like drawing a horizontal line)?

@damianavila
Copy link
Member Author

for the record, though I do think we need a keyboard shortcut for splitting cells, Ctrl-m 7 was not what I had in mind ;)

he he he ;-)

Is Ctrl-M - available for split (like drawing a horizontal line)?

I like it... I assume that you think the merge function can wait for shortcuts... ;-)

@minrk
Copy link
Member

minrk commented Jul 9, 2013

I assume that you think the merge function can wait for shortcuts... ;-)

I just don't have an idea for what they should be. If I remember correctly, we can switch on shift, so maybe shift-A and shift-B for merge above/below? shortcuts are precious, and I think merge is not a high priority action (select/cut/up/paste covers it - a bit slow, but not difficult).

@damianavila
Copy link
Member Author

I just don't have an idea for what they should be. If I remember correctly, we can switch on shift, so maybe shift-A and shift-B for merge above/below? shortcuts are precious, and I think merge is not a high priority action (select/cut/up/paste covers it - a bit slow, but not difficult).

Yeah, I know they are precious, I can live without merge shortcuts for now... ;-)

OK, I like Ctrl-M - for splitting purpose... anyone else has something to say... if not I will update the PR only with the shortcut split, we can discuss later (probably in another PR after the land of the dual mode) if we need the merge ones.

@Carreau
Copy link
Member

Carreau commented Jul 9, 2013

I just don't have an idea for what they should be. If I remember correctly, we can switch on shift, so maybe shift-A and shift-B for merge above/below? shortcuts are precious, and I think merge is not a high priority action (select/cut/up/paste covers it - a bit slow, but not difficult).

I must admit that with shift-cmd-down, cmd-x,C-m,b,cmd-v I'm pretty fast too to split too.

@damianavila
Copy link
Member Author

I must admit that with shift-cmd-down, cmd-x,C-m,b,cmd-v I'm pretty fast too to split too.

But not enough fast when you have to split multiple times when you are formatting a large document or change types of slides in your slideshows... I can live without merge shortcuts, but not having a split shortcut is actually annoying, because you (I mean, I... maybe the workflow of others is different) split cells with a high frequency ;-)

@ellisonbg
Copy link
Member

I like the Ctrl-M - shortcut

On Tue, Jul 9, 2013 at 1:00 PM, Damián Avila notifications@github.comwrote:

I must admit that with shift-cmd-down, cmd-x,C-m,b,cmd-v I'm pretty fast
too to split too.

But not enough fast when you have to split multiple times when you are
formatting a large document or change types of slides in your slideshows...
I can live without merge shortcuts, but not having a split shortcut is
actually annoying, because you (I mean, I... maybe the workflow of others
is different) split cells with a high frequency ;-)


Reply to this email directly or view it on GitHubhttps://github.com//pull/3571#issuecomment-20701154
.

Brian E. Granger
Cal Poly State University, San Luis Obispo
bgranger@calpoly.edu and ellisonbg@gmail.com

@ellisonbg
Copy link
Member

I am OK with this as is, how do others feel about the Crtl-M - shortcut?

@ivanov
Copy link
Member

ivanov commented Jul 10, 2013

+1 on Ctrl-M -

@Carreau
Copy link
Member

Carreau commented Jul 10, 2013

Neutral for me.

@damianavila
Copy link
Member Author

OK, we have at least three :+1 and one neutral... anyone else out there to make a vote? ;-)

@Carreau
Copy link
Member

Carreau commented Jul 11, 2013

@ellisonbg this will conflict with your #3605 what should we do ?

@jakobgager
Copy link
Contributor

Neutral for me too, as I've never used the split option but don't see a reason not to implement this shortcut.

@jasongrout
Copy link
Member

For merging in the Sage notebook---if you are at the first position in a cell and press backspace, it will merge with the previous cell. That's a way to do it without shortcut keys, and is rather natural.

@ellisonbg
Copy link
Member

It is probably easiest if I just add this to my PR.

On Thu, Jul 11, 2013 at 5:17 AM, Matthias Bussonnier <
notifications@github.com> wrote:

@ellisonbg https://github.com/ellisonbg this will conflict with your
#3605 #3605 what should we do ?


Reply to this email directly or view it on GitHubhttps://github.com//pull/3571#issuecomment-20806911
.

Brian E. Granger
Cal Poly State University, San Luis Obispo
bgranger@calpoly.edu and ellisonbg@gmail.com

@damianavila
Copy link
Member Author

OK, after listen to Brian, I think we can merge it ;-)

minrk added a commit that referenced this pull request Jul 15, 2013
Added `^M -` as shorcut to split cell.
@minrk minrk merged commit 6ae26af into ipython:master Jul 15, 2013
@damianavila damianavila deleted the split_shortcut branch July 15, 2013 18:53
@damianavila
Copy link
Member Author

Thanks! I love the split shortcut 👍

@dpsanders
Copy link
Contributor

Just found this discussion -- +1 for the split shortcut!

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
Added `^M -` as shorcut to split cell.
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.

None yet

9 participants