question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add encapsulate with parentheses (quotes, brackets, braces) function

See original GitHub issue

Encapsulating parentheses and others

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?

  1. highlight some code
  2. press opening parenthesis key

What is the expected output? What do you see instead?

  • The text should be surrounded by parenthesis.
  • The text was replaced.

Versions and main components

  • Spyder Version: 2.3.9 (in an Anaconda env for Python 3.5)
  • Python Version: Python 3.5
  • Operating system: Fedora 22

Dependencies

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)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:9
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
bcolsencommented, Jul 30, 2018

@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!

2reactions
Diego-MXcommented, Aug 7, 2017

If I may add something to this request, also enclose selection with brackets, curlies, and quotes, when the corresponding key is pressed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Parentheses vs. Brackets - The College of Saint Rose
In a paper, use brackets to signify important information added to direct quotes. The brackets tell the reader that the information is added...
Read more >
How to Use Brackets in Academic Writing: Some Common Rules
Usually, enclose an ellipsis in brackets. MLA suggests that parentheses (round brackets) be used; CMOS suggests using square brackets; and some style guides, ......
Read more >
When To Use Brackets in Quotes: Your Punctuation Guide
Not sure when to use brackets in quotes and when to use parentheses? Not to worry. We clear everything up in this handy...
Read more >
When should I use curly braces { } and parenthesis ( ) in React?
Curly braces { } are special syntax in JSX. It is used to evaluate a JavaScript expression during compilation. A JavaScript expression can...
Read more >
How To Use Braces { } as Punctuation | YourDictionary
Braces vs. Brackets · Parentheses ( ) add additional information or provide information and detail that is helpful to have. · Square brackets...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found