I'm using jupyter-vim-binding. I can toggle line numbers with C-o, Shift-L
. How can I enable line number upon start-up (i.e. when creating a new code cell)? I'm aware of the customization js file but I'm afraid of breaking the current setup, so would like answers from more seasoned users.
Asked
Active
Viewed 715 times
3

tnabdb
- 517
- 2
- 8
- 22
-
1autocommand might help: http://learnvimscriptthehardway.stevelosh.com/chapters/12.html – Sundeep Aug 02 '16 at 03:36
-
For normal vim, it would be `:au BufEnter *.* :set nu
`. Put this line in your ~/.vimrc. When you open any file, you will see the line numbers. – SibiCoder Aug 02 '16 at 05:35 -
Related: http://stackoverflow.com/questions/20197471/how-to-display-line-numbers-in-ipython-notebook-code-cell-by-default – zarak Aug 02 '16 at 07:50
-
New, better answer: https://stackoverflow.com/a/55035981/230468 – DilithiumMatrix Nov 11 '20 at 14:57
1 Answers
3
The Jupyter Notebook docs show an example to change the default indentation of code cells. You can follow the instructions on that page, but instead pass the lineNumbers
argument:
var cell = Jupyter.notebook.get_selected_cell();
var config = cell.config;
var patch = {
CodeCell:{
cm_config:{lineNumbers:true}
}
}
config.update(patch)
You should still be able to toggle line-numbers with the jupyter-vim-binding
shortcut.

zarak
- 2,933
- 3
- 23
- 29
-
1Thanks. I pasted the code you provided in the Javascript console and it worked. – tnabdb Aug 02 '16 at 13:30