DEV Community

Cover image for VIM & Visual Studio Code Tips & Tricks (With Video / GIF)
Muhammad Muhajir
Muhammad Muhajir

Posted on • Updated on

VIM & Visual Studio Code Tips & Tricks (With Video / GIF)

This post is going to be a collection of VIM And Visual Studio Code tips that I use daily. And it will be updated frequently. So stay tuned. You can follow me here or on twitter @muhajirdev if you want. I'd really really love to hear your feedback here

Installed Extenstion in Visual Studio Code:

Delete In Tag

dit-2.gif

Delete Surrounding Tag

dst-2.gif

Update June 30th, 2019

Change single quote to double quote

single-quote-to-double-quote.gif

Update July 4th, 2019

Change Tag with Emmet

Note that you need to set the keyboard shortcut first. Press cmd+shift+p Then write Preferences: Open Keyboard Shortcuts (JSON). And add the following

[
...
 {
    "key": "shift+cmd+n",
    "command": "editor.emmet.action.updateTag",
    "when": "editorTextFocus"
  },
...
]
Enter fullscreen mode Exit fullscreen mode

My full keyboard shortcuts can be seen on my github dotfiles

change-tag.gif

Update July 11th, 2019

Go to matching tag with Emmet

Similar to tips above. I use cmd+m as the shortcut here. You can check the keyboard shortcut file on my github dotfiles.

matching tag.gif

Copy And Paste with VIM

copy-paste.gif

Update

I have created VSCode.xyz as vscode tips and tricks portal. Check it out.

This post will be updated with more tips and tricks. Stay tuned.

Like and share if you found it useful.

If you have additional tips. You can put it on the comment below. I might can include it too in this post :)

Top comments (15)

Collapse
 
_sinharakshit_ profile image
Rakshit Sinha ⚡

Inspired by your 3rd tip, when inside an HTML/JSX tag:
Using cs<div> can change your current tag to a <div> tag. Of course, that is applicable to all other types of HTML tags out there. <div> was just for an example.

Collapse
 
muhajirdev profile image
Muhammad Muhajir

Cool

Collapse
 
stuartaylward profile image
stuartaylward

Did I miss something? How does this work? Is there a shortcut key combination to make this work?

Collapse
 
muhajirdev profile image
Muhammad Muhajir

Hi stuart,
Did you manage to get it working?

First of all you need to install github.com/VSCodeVim/Vim . And you can learn some vim basic here openvim.com .

After that, all those tips & tricks should be usable

Collapse
 
z2lai profile image
z2lai

Yeah, I'm feeling quite confused and stupid right now...

Collapse
 
muhajirdev profile image
Muhammad Muhajir • Edited

Ah, my bad. Should have said that we're using VSCode Vim extension. I'll update the post. Thanks for noticing

Collapse
 
muhajirdev profile image
Muhammad Muhajir

Yeah. We're using VSCode VIM extension like mentioned by @firozansari . I'll update the post. Thanks for noticing

Collapse
 
gypsydave5 profile image
David Wickes

Worth pointing out that cs relies on (vim-surround)[github.com/tpope/vim-surround] in actual Vim.

Collapse
 
muhajirdev profile image
Muhammad Muhajir

Yeah, it's awesome. Thanks for adding the information David :)

Collapse
 
agracy2246 profile image
Adam Gracy

Here is more evidence bad things come in threes.

Collapse
 
muhajirdev profile image
Muhammad Muhajir

😂😂

Collapse
 
firozansari profile image
Firoz Ansari

I am not sure but look like you are using VS Code Vim Extension.

Collapse
 
muhajirdev profile image
Muhammad Muhajir

Right I am using that extension

Collapse
 
muhajirdev profile image
Muhammad Muhajir

Update

I have launched vscode.xyz for this purpose. Check it out

Collapse
 
dr1verrr profile image
Danylo

Oh why I didn't see this article before. Always used auto rename tag ext cuz have no alternatives