10

This may sound like a silly question, but how do I make use of the autoclose brackets in Jupyter notebook? For example, when I type

print(

Jupyter notebook auto-closes the brakets

print()

and places the cursor inside. Then I could type the argument, say

print(1 + 1)

now my cursor is between the second 1 and the right bracket ). What is the key to navigate to the right of )?

Of course I can press End or or even ) to achieve this, but it does not seem to save time, which is the purpose of the brackets autoclose I suppose?

Thanks in advance.

Y. Pei
  • 305
  • 3
  • 11
  • 1
    ')' will get you to the right of the paren. The purpose is not for simple cases like above but more complex cases, every time you open a bracket it puts the corresponding close to help you keep track of things - e.g. `l = [(i.split( ...` has autoclosed `))]`. – AChampion Nov 21 '16 at 20:17
  • @AChampion Since the question is unanswered for a (long) while, what about you posting that as an answer? (although since apparently op asks "what's the purpose of... it can be opinion-based; in that case the question can be closed, but the answer can be posted to the older question that I linked here) – user202729 Jan 04 '21 at 08:00
  • The inefficient implementation of [pair closing](https://codemirror.net/addon/edit/closebrackets.js) (quote, parenthesis, bracket) in [Code Mirror](https://codemirror.net/doc/manual.html) is a significant wasting of time and a source of parsing errors when you need to add these elements afterwards (closing element silently discarded, pair of quotes inserted). Just consider [not to use it](https://stackoverflow.com/q/22843891/774575) and type the closing element manually. Disappointing feature of a otherwise fantastic tool. – mins Jan 17 '21 at 10:25

1 Answers1

6

We can do that from the jupyter console, try it.

enter image description here

muntasir kabir
  • 168
  • 2
  • 13