Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Surround a text/word with special characters #1307

Closed
danielschmitz opened this issue Dec 14, 2015 · 12 comments
Closed

Surround a text/word with special characters #1307

danielschmitz opened this issue Dec 14, 2015 · 12 comments
Assignees
Labels
feature-request Request for new features or functionality markdown Markdown support issues verified Verification succeeded
Milestone

Comments

@danielschmitz
Copy link

Surround a text/word with special characters by selecting it and pressing the special character.

example:

@hashhar
Copy link
Contributor

hashhar commented Dec 14, 2015

Woah!!! We need this, but this looks to be better suited as an extension really. It should have some kind of modifier key though because I sometimes would like to replace a word with a special character.

Maybe Alt + special character?

@dbaeumer dbaeumer added feature-request Request for new features or functionality markdown Markdown support issues labels Dec 15, 2015
@dbaeumer dbaeumer added this to the Backlog milestone Dec 15, 2015
@dbaeumer
Copy link
Member

@bpasero Ben, start with you here since this sounds like a mark down feature. I think there is no underlying support needed in the editor to make this happen.

@bpasero bpasero removed their assignment Dec 15, 2015
@danielschmitz
Copy link
Author

Hello guys, its a mark down "native" feature.

Thanks

@OceanAirdrop
Copy link

Yes, this is similar to the plugin for the brackets IDE.

Very useful for wrapping html elements around selected text.

http://www.granneman.com/webdev/editors/brackets/extensions/surround/
https://github.com/pedelman/brackets-surround

+1 from me!

@JVimes
Copy link

JVimes commented Apr 12, 2016

Great in any language for quotes/brackets/parens. User expects to be able to overwrite text by highlighting and typing, so @hashhar's suggestion is on the right track. Alt might not work right on Mac, since it's already used by the system to insert special characters (like ÷«“‘ªº). But other modifier(s) should.

@jorgeas80
Copy link

Need this!

@hashhar
Copy link
Contributor

hashhar commented Nov 20, 2016

Maybe someone can take a look at how they implemented the surround with quotes to get an idea to extend it. I think after v1.6 we could select text and press " or ' and that surrounded the text.

EDIT: Found it. https://github.com/Microsoft/vscode/blob/c80de308d5ac76d9db02c0a9a2c9ac3417071af5/src/vs/editor/common/commands/surroundSelectionCommand.ts

EDIT 2: See this for learning how to achieve this currently. Currently this feature is available when autoClosingBrackets is enabled.

@M-Zuber
Copy link

M-Zuber commented Dec 20, 2016

What I would want is full surround with like exists in Visual Studio see here for super quick intro which would let me use any snippet in addition to punctuation.
It is very handy for things like moving code into an if or try/catch.

The far dream would have us be able to declare an arbitrary punctuation pair and use that like we can now with (), [], ect.

Most of this functionality could be hidden behind a shortcut like ctrl+k, s for those who are worried about it interfering with basic typing.

@bickycheese
Copy link

bickycheese commented Dec 30, 2016

Was suprised to see the behaviour for markdown files concerning surrounding selected text with the typed character is different from say js, html, css, ... files. Was this by design intended to exclude md files from this behaviour?

@sethlivingston
Copy link

Parity with Visual Studio would be great here. I know it can be an extension, but IMHO this should be built in or a pre-installed extension.

@spacegoing
Copy link

How can I enable this feature in markdown files? Which command implements this?

@mjbvz mjbvz self-assigned this Mar 24, 2017
@mjbvz mjbvz added the help wanted Issues identified as good community contribution opportunities label Apr 7, 2017
@mjbvz mjbvz modified the milestones: April 2017, Backlog Apr 7, 2017
@mjbvz mjbvz removed the help wanted Issues identified as good community contribution opportunities label Apr 7, 2017
@mjbvz mjbvz closed this as completed in 8fbad6e Apr 7, 2017
@mjbvz
Copy link
Contributor

mjbvz commented Apr 7, 2017

I just pushed 8fbad6e which adds this feature for markdown. To use it, select some text in markdown and trigger the insert snippet command. The bold, Italic, and inline code snippets for markdown all have this enabled now.

Here's the reason a snipped based approach was selected and how other extensions/languages can implement this sort of functionality:

For basic surround logic, extensions can use the surroundWith language configuration option. Adding * for the surroundWith in the markdown language configuration allows the behavior that @danielschmitz originally described. surroundWith can also be configured separately from autoClosingPairs.

However, in testing, I was concerned that surroundWith for * and other special characters may get in the way of too many users. That's why I went with a more explicit snippet based approach. This makes use of the TM_SELECTED_TEXT value present in snippets:

	"Insert bold text": {
		"prefix": "bold",
		"body": "**${1:${TM_SELECTED_TEXT}}**$0",
		"description": "Insert bold text"
	},

Any extension can contribute snippets that make use of this pattern. Feel free to submit a PR if you would like any of the other markdown snippets to use the surround logic as well


Please let me know if you have any questions or concerns about the current approach

@mjbvz mjbvz added the verification-needed Verification of issue is requested label Apr 25, 2017
@sandy081 sandy081 added verified Verification succeeded and removed verification-needed Verification of issue is requested labels Apr 26, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality markdown Markdown support issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests