简体   繁体   中英

How to make new cells in ipython notebook markdown by default?

Currently, whenever you create a new cell in an iPython notebook, it defaults to a opening up a cell for Python code. I can then change it to markdown by hitting the keyboard shortcut ctrl m m

Is there any method or any setting I can tweak so that new cells default to being in "markdown mode"?

I did find this question which appears to ask the same thing, but it was erroneously flagged as a duplicate and wasn't answered.

I was just reading the IPython notebook js code, and found the insert_cell_below method at https://github.com/ipython/ipython/blob/master/IPython/html/static/notebook/js/notebook.js#L849 .

If you want to do this programatically, it would simply be a case of doing something like:

from IPython.display import display, Javascript

def markdown_below():
    display(Javascript("""
    IPython.notebook.insert_cell_below('markdown')
    """));

markdown_below()

This would be fairly early to turn into a button on the toolbar in a similar way to the gist button in https://github.com/minrk/ipython_extensions .

HTH

Quote from Brian E. Granger in 2012 from this forum: http://python.6.x6.nabble.com/Start-notebook-with-custom-markdown-code-snippets-as-default-td4997506.html

The best way of doing this right now is to clone an existing notebook. We don't have a great way of doing that, but starting in Jan, we will be working on the dashboard and we will add things like that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM