I want to be able to highlight code and press the button for some beginning character like the opening parenthesis, so that the whole highlighted text is surrounded by an opening parenthesis on the left and a closing parenthesis on the right, as an example. Many editors support this kind of behavior and I have gotten used to being able to do this.
What steps will reproduce the problem?
What is the expected output? What do you see instead?
Please go to the menu entry Help > Optional Dependencies
(or
Help > Dependencies
), press the button Copy to clipboard
and paste the contents below:
IPython >=1.0 : 5.1.0 (OK)
jedi >=0.8.1;<0.9.0: 0.9.0 (NOK)
matplotlib >=1.0 : 1.5.1 (OK)
pandas >=0.13.1 : 0.18.1 (OK)
pep8 >=0.6 : 1.7.0 (OK)
psutil >=0.3 : 4.3.1 (OK)
pyflakes >=0.6.0 : 1.3.0 (OK)
pygments >=1.6 : 2.1.3 (OK)
pylint >=0.25 : None (NOK)
qtconsole >=4.0 : 4.2.1 (OK)
rope >=0.9.2 : 0.9.4-1 (OK)
sphinx >=0.6.6 : 1.4.1 (OK)
sympy >=0.7.3 : None (NOK)
zmq >=2.1.11 : 15.4.0 (OK)
Good idea. It shouldn't be that hard to implement :-)
If I may add something to this request, also enclose selection with brackets, curlies, and quotes, when the corresponding key is pressed.
Would like to implement this if someone points me to the right direction in the code.
I would start by studying https://github.com/spyder-ide/spyder/blob/da167e4e088373bcb3028112027c3eddab34c14f/spyder/widgets/sourcecode/codeeditor.py#L2668
That block automatically inserts the closing parenthesis when you type the opening parenthesis in foo(
.
Good luck!
@h4gen Spyder already has quote insertion for selected text in master. If you select text and press the '
or "
key the selection will get quoted.
This functionality is now implemented as the first example of an editor extension:
https://github.com/spyder-ide/spyder/blob/master/spyder/widgets/sourcecode/extensions/closequotes.py
This section does the part you want to do with brackets:
I think you will want to write an editor extension similar to closequotes extension. See this PR for more info.
https://github.com/spyder-ide/spyder/pull/5002
Sounds like a fun project!
@ccordoba12 Hope you didn't have anyone particular in mind to fix this one because I had some time today so I wrote a close bracket extension that fixes this.
No, not at all. Thanks for your help in solving this one!
Most helpful comment
@h4gen Spyder already has quote insertion for selected text in master. If you select text and press the
'
or"
key the selection will get quoted.This functionality is now implemented as the first example of an editor extension:
https://github.com/spyder-ide/spyder/blob/master/spyder/widgets/sourcecode/extensions/closequotes.py
This section does the part you want to do with brackets:
https://github.com/spyder-ide/spyder/blob/da167e4e088373bcb3028112027c3eddab34c14f/spyder/widgets/sourcecode/extensions/closequotes.py#L71-L78
I think you will want to write an editor extension similar to closequotes extension. See this PR for more info.
https://github.com/spyder-ide/spyder/pull/5002
Sounds like a fun project!