<div dir="ltr">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.<div><br>
</div><div>Aaron Meurer</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Apr 3, 2014 at 9:46 PM, Paul Ivanov <span dir="ltr"><<a href="mailto:pi@berkeley.edu" target="_blank">pi@berkeley.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">Greg Wilson, on 2014-04-03 18:37, wrote:<br>
> Hi,<br>
> I'd like to put literal tab characters in cells, but of course tab means<br>
> "indent" to the editor. What's the easiest way to do this?<br>
> Thanks,<br>
> Greg<br>
> p.s. because I'm going to write Makefiles in the notebook...<br>
<br>
</div>Here you go, Greg:<br>
<br>
<a href="http://nbviewer.ipython.org/url/pirsquared.org/blog/notebooks/indenting-tabs.ipynb" target="_blank">http://nbviewer.ipython.org/url/pirsquared.org/blog/notebooks/indenting-tabs.ipynb</a><br>
<br>
The TL;DR version is - you can toggle tab-literal insertion via:<br>
<br>
%%javascript<br>
<br>
IPython.tab_as_tab_everywhere = function(use_tabs) {<br>
if (use_tabs === undefined) {<br>
use_tabs = true;<br>
}<br>
<br>
// apply setting to all current CodeMirror instances<br>
IPython.notebook.get_cells().map(<br>
function(c) { return c.code_mirror.options.indentWithTabs=use_tabs; }<br>
);<br>
// make sure new CodeMirror instances created in the future also use this setting<br>
CodeMirror.defaults.indentWithTabs=use_tabs;<br>
<br>
};<br>
<br>
And then just call<br>
<br>
%%javascript<br>
<br>
IPython.tab_as_tab_everywhere();<br>
<br>
I believe you already have code to add buttons to the toolbar<br>
that Matthias and Min supplied in the past, so hooking those<br>
things up would be a breeze.<br>
<br>
best,<br>
--<br>
_<br>
/ \<br>
A* \^ -<br>
,./ _.`\\ / \<br>
/ ,--.S \/ \<br>
/ `"~,_ \ \<br>
__o ?<br>
_ \<,_ /:\<br>
--(_)/-(_)----.../ | \<br>
--------------.......J<br>
<span class="HOEnZb"><font color="#888888">Paul Ivanov<br>
<a href="http://pirsquared.org" target="_blank">http://pirsquared.org</a><br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org">IPython-dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
</div></div></blockquote></div><br></div>