[IPython-User] Swap enter and shift-enter in notebook?

Michael McNeil Forbes michael.forbes@gmail....
Thu Aug 2 19:23:45 CDT 2012

On 2 Aug 2012, at 12:39 AM, Matthias Bussonnier wrote:
> Sorry for the brievty, answer from my phone.
> If you use 0.14 dev. you can overwrite ipython file without touching  
> the server.
> Just add them into .ipython/profile/profile_xxx/

This seems to work fine:
1) Install IPython 0.14-dev from github on server.
2) Copy notebook.js and codecell.js to ~/.ipython/profile/profile_xxx/ 
static/js/ from
    Note: this profile name must match the name of the profile on the  
server. This is a
    little strange in terms of UI since the name of this profile is  
not even visible
    from the web interface, but probably makes sense from a dev.  
perspective to localize
    the effects.
3) Swap the shift-flag near as follows

         if (event.which == key.ENTER) {
             // MMF Customization: swap enter and shift-enter
             event.shiftKey = !event.shiftKey;

     Do this near the start of the following function in codecell.js

        CodeCell.prototype.handle_codemirror_keyevent = function  
(editor, event) {

     and near the start of the following block in notebook.js

        $(document).keydown(function (event) {

While I am at it I might add a sequence for joining two adjacent  
blocks.  Is there
a function that will do this simply?


More information about the IPython-User mailing list