Spyder: Add Ctrl+] and Ctrl+[ as indent and unindent shortcuts

Created on 6 Sep 2016  路  14Comments  路  Source: spyder-ide/spyder

This is a feature request.
ctrl ] and ctrl [ are super common shortcuts to indent current line/block and unindent current line/block.
This is different from Tab because Tab inserts a tab if pressed in the middle of a line and only works as indent line if the line is selected.
In other ides (sublime, and notebook) you don't have to select the line before pressing shift [ or ]

Thanks!

Editor Enhancement

Most helpful comment

I like the idea, now that it's Ctrl + [ and not Left Shift + [

All 14 comments

Thanks for the suggestion. Are there any other IDEs using this?


This is an easy fix an a great place to start contributing to Spyder (if @spyder-ide/core-developers think is a good idea)

editors that have this behavior by default:

  • IDLE
  • Sublime Text
  • Jupyter Notebook
  • Atom
  • Textmate
  • Matlab
  • maybe more but I didn't check

The fact that it is default in IDLE and Jupyter Notebook is the prevailing reason since python people are used to it.

@talkaminker thanks for the feedback. You are welcome to submit a PR :-), if you need some pointers let us know

I made a mistake before, I meant ctrl + [ and ctrl + ].
these are the commonly used ones (in all the ide's I mentioned), not shift [ and shift ]
I updated the feature ticket. oops my bad.
In any case, can I develop this? did it get approved by @spyder-ide/core-developers ?

Well if all those other IDEs are using it, I say go for it!

I like the idea, now that it's Ctrl + [ and not Left Shift + [

:+1:

The best thing we can do to fix this (and other shortcuts related stuff, like the use of Ctrl+Enter to execute a single line, requested by RStudio users) is to remove fixed shortcuts and make all our shortcuts configurable. That way people could adjust everything to their likings :-)

This is my plan for 3.1 :-)


@goanpeca, you were right at the end: fixed shortcuts were a bad idea ;-p

:-)

If we are on the subject, also would be cool to allow assign multiple shortcuts for the same operation (like pycharm and sublime text allows)
And be able to export all the shortcuts and import them in a different instance of spyder.
Sublime text for example uses one huge json to define all the shortcuts.

allow assign multiple shortcuts for the same operation

Could you paste a screenshot of the interface where multiple shortcuts are defined (for either pycharm or sublime.. or both?)

And be able to export all the shortcuts and import them in a different instance of spyder.

Sure, this one is an easy one, could you open a new issue for that as a feature request?

The pycharm way is the most straightforward
Here you see the keymap menu where you search for a shortcut. and right-clicking on the line will give you the small menu you see where you can remove any of the previous shortcuts. Each small yellow balloon is the shortcut.

pycharm_two_shortcuts

Clicking on "Add Keyboard Shortcut"
will result in the following menu:

pycharm_two_shortcuts

Where you click on the keyboard the shortcut you want and it will automatically write it down. In this example, I hit Shift+8. if the shortcut already exists it will tell you and ask you if you want to remove the second shortcut.

Note that you can also disable a shortcut completely if you don't like the operation

I second this. Cmd+[ and Cmd+] is very conventional today to use for indent/unindent.

At the very least, it should be configurable, but it's nowhere to be found in Preferences->Keyboard shortcuts.

@rlaverde, please implement this by making the shortcuts to indent/unindent configurable.

Was this page helpful?
0 / 5 - 0 ratings