[IPython-dev] Shortcut to convert cell between code and markdown while remaining in edit mode?

MinRK benjaminrk at gmail.com
Sun Apr 20 14:03:14 EDT 2014

We probably won’t add this to the default shortcuts, but this is the reason
shortcuts are customizable now. You can add a shortcut to do this in
custom.js, with:

IPython.keyboard_manager.edit_shortcuts.add_shortcut('ctrl-y', {
    help : 'toggle markdown/code',
    handler : function (event) {
        var cell = IPython.notebook.get_selected_cell();
        if (cell.cell_type == 'code') {
        } else if (cell.cell_type == 'markdown') {
        return false;

in your custom.js


On Sun, Apr 20, 2014 at 10:09 AM, Maximilian Albert <
maximilian.albert at gmail.com> wrote:

> Hi all,
> First of all a big word of thanks to the entire team for all the great and
> hard work! I'm using IPython for pretty much all of my work and it gets
> better and better by the day and is a joy to use. :)
> I have a small remark/request about the new modal interface for the
> notebook. I really like it in most ways, but it would be great if there was
> a way to convert a cell from code to markdown (and vice versa) *without
> having to leave edit mode*.
> Background: I frequently find myself in a situation where I just executed
> a code cell and now want to enter a few descriptive sentences for the next
> piece of code. So I start typing, but since I just executed a code cell the
> current cell is also a code cell. I realise this after a few words and then
> have to execute three key strokes:
>    Esc  -> go into command mode
>    m  -> convert cell to markdown
>    Enter  -> enter edit mode
> Since all of these keys are at different positions on the keyboard, it
> makes this process a bit cumbersome, especially because I always lose half
> a second or so between each key stroke to check whether it actually did
> what I expected it to do. It's not a major problem, but it is annoying
> enough to get in my way because it interrupts the mental flow while I'm
> focusing on how to write a (possibly non-trivial) explanation for the next
> bit of code.
> So it would be great if there was a way to simply convert a cell from code
> to markdown with a single keyboard shortcut, while *remaining in edit mode*.
> Suggestions:
> - Currently, the shortcuts "Ctrl-m" and "Esc" have the same meaning in
> edit mode (viz., "enter command mode"). Why not change the meaning of
> "Ctrl-m" to: "convert current cell to markdown and remain in edit mode"?
> This plays nicely with the fact that "m" on its own (without Ctrl) converts
> a cell to markdown when in command mode.
> - It would be nice to have a similar shortcut for the "reverse" operation
> "convert current cell to code cell and remain in edit mode". I would have
> suggested "Ctrl-y" for this (due to the same mnemonic reason, since "y"
> alone has the same meaning in command mode). But this is already used for
> "redo". But I'd be happy with any other shortcut, too.
> Apologies for this long email for such a simple request. Thanks for
> reading, and thanks for considering it!
> Best wishes,
> Max
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140420/2d1ea17d/attachment.html>

More information about the IPython-dev mailing list