Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code Surround With

I can't find any way to surround a selection with something in VS Code.

For example doing something like that : text => "text" just by selecting the word text and typing key "

Another example with the following text : mon tue wed thu fri sat sun

By selecting all of theses words :

mon| tue| wed| thu| fri| sat| sun|

and typing " I would like to perform something like this :

"mon" "tue" "wed" "thu" "fri" "sat" "sun"

If someone have any idea.

Thanks.

like image 669
Ronan Lamour Avatar asked Feb 21 '17 09:02

Ronan Lamour


People also ask

How do I surround with Visual Studio?

In the Visual Studio IDE, open the file that you intend to edit. In the Code Editor, select text to surround. Right-click the selected text. Then, in the right-click context menu, select Snippet > Surround With.

How do I enable side preview in VS Code?

To switch between views, press Ctrl+Shift+V in the editor. You can view the preview side-by-side (Ctrl+K V) with the file you are editing and see changes reflected in real-time as you edit.

Can VS Code run on 2gb RAM?

VS Code is lightweight and should easily run on today's hardware. We recommend: 1.6 GHz or faster processor. 1 GB of RAM.

How do you split screen on VS Code?

Ctrl+\ to split the active editor into two. Open to the Side (Ctrl+Enter) from the Explorer context menu on a file. Click the Split Editor button in the upper right of an editor. Drag and drop a file to any side of the editor region.


1 Answers

Selecting some text and pressing " already works in VSCode to surround a single item, and works for multi-line selections as well.

NOTE: this is language dependent. The language syntax must define opening and closing braces, e.g. quotes, braces, etc. So this will not work in a "plaintext" file, for example. Change your language mode with CTRL+SHIFT+P and type Change Language Mode ENTER and select something like JavaScript where this is supported.

What you are after though is not really that efficient like that. Your best bet is to use multi-cursors.

Place the cursor at the start of the first line, press CTRL+ALT+DOWN to add another cursor below on the next line. Keep doing that until you have a cursor in front of all your words.

Then just type " then END then " and all your lines are surrounded by quotes.

NB: To check if you have a key bound, and what it is, you can always press CTRL+SHIFT+P and type Add Cursor Below and if there's a keybinding it will show to the right of that text.

like image 92
MartinSGill Avatar answered Sep 25 '22 00:09

MartinSGill