[IPython-dev] easiest way to insert a literal tab character in a code cell?
Aaron Meurer
asmeurer at gmail.com
Fri Apr 4 00:20:02 EDT 2014
Since you asked for the easiest way, I should point out that you can just
paste a tab into a code cell. If you need one to paste, just type
print('\t') and copy the whitespace below the cell.
Aaron Meurer
On Thu, Apr 3, 2014 at 9:46 PM, Paul Ivanov <pi at berkeley.edu> wrote:
> Greg Wilson, on 2014-04-03 18:37, wrote:
> > Hi,
> > I'd like to put literal tab characters in cells, but of course tab means
> > "indent" to the editor. What's the easiest way to do this?
> > Thanks,
> > Greg
> > p.s. because I'm going to write Makefiles in the notebook...
>
> Here you go, Greg:
>
>
> http://nbviewer.ipython.org/url/pirsquared.org/blog/notebooks/indenting-tabs.ipynb
>
> The TL;DR version is - you can toggle tab-literal insertion via:
>
> %%javascript
>
> IPython.tab_as_tab_everywhere = function(use_tabs) {
> if (use_tabs === undefined) {
> use_tabs = true;
> }
>
> // apply setting to all current CodeMirror instances
> IPython.notebook.get_cells().map(
> function(c) { return
> c.code_mirror.options.indentWithTabs=use_tabs; }
> );
> // make sure new CodeMirror instances created in the future also
> use this setting
> CodeMirror.defaults.indentWithTabs=use_tabs;
>
> };
>
> And then just call
>
> %%javascript
>
> IPython.tab_as_tab_everywhere();
>
> I believe you already have code to add buttons to the toolbar
> that Matthias and Min supplied in the past, so hooking those
> things up would be a breeze.
>
> best,
> --
> _
> / \
> A* \^ -
> ,./ _.`\\ / \
> / ,--.S \/ \
> / `"~,_ \ \
> __o ?
> _ \<,_ /:\
> --(_)/-(_)----.../ | \
> --------------.......J
> Paul Ivanov
> http://pirsquared.org
> _______________________________________________
> 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/20140403/912b5a0e/attachment.html>
More information about the IPython-dev
mailing list