-1

I wanted to try vim for a bit, and get used to it... i got stuck with trying to replicate Ctrl+D functionality of VScode... so I've tried couple Google solutions.

This is What I've tried when I got that error: :g/oldword/norm newword
I see lots of people do search patterns like this, but it's annoying I get this message, without being able to find solution on google :D

I know I can solve this issue with /word then cgn newword and then just repeat with . operator, BUT, I want to be able to use the global command for searching patterns and stuff, for other purposes too, and it stresses me out that I can't make it work!

Here is the error I am getting.

Any help is extremely appreciated / welcome! Thanks.

Edit: Forgot to mention: We are talking about Vim for VScode, not the gvim installation stuff. Will try to install that too, and update the question.

Edit2: Okay so apparently, after instalilng gvim (from official site) and ran it through vim command in cmd prompt, the official vim can run the :g commands.
Like (for example) if you want to search for <a> and replace it with <router-link> you can do so by: :g/<a>/norm ciw<router-link>
Which means:

  • :g/<a>/norm run a global (file) search for pattern <a>
  • ciw - change in word
  • <router-link> the replacement pattern for <a> Note: The same should be done for </a> after that :D

The problem still exists tho.
While the native vim exe (outside of vscode) works and can run these stuffs, I still need to fix the vscode one (the extension that is). It is defo nice to have syntax highlighting and correction.

JaneZ
  • 11
  • 2

3 Answers3

3

What you are using is not Vim. It is a Vim emulator which, like all Vim emulators, can't be expected to be either complete or accurate. Its only relationship with Vim is that it tries and fails to imitate it.

Some of the Vim stuff you will find on the internet will work in that VSCode extension exactly as it does in Vim, some of it will work but partially or differently, and most of it, like :g, will simply not work.

There is nothing you can do about that except, maybe, contributing to the project.

romainl
  • 186,200
  • 21
  • 280
  • 313
  • Thank you kindly for the clarification, mate. I will soon switch to the native vim, just need to ditch couple VScode habits first. I was also assuming that, but thought it might have some plugin or extension that extend that functionality, or add it, or something. Either way, I appreciate your help :) <3 – JaneZ Apr 12 '21 at 22:37
1

The easiest way to get this working is to enable neovim in the VS Code Vim extension you're using.

Once you have installed Neovim on your operating system, you can enable it within VSCode inside the Preferences: User Settings window:

  1. Enable the Vim: Enable Neovim option (vim.enableNeovim)
  2. Set the path to Neovim inside the Vim: Neovim Path setting (vim.neovimPath)
  3. Restart VSCode

Source: https://www.barbarianmeetscoding.com/boost-your-coding-fu-with-vscode-and-vim/integrating-vscode-with-neovim/#enabling-neovim-inside-vscode

0

If you want support for the global command in VSCode, install Neovim and the VSCode extension for it:

for those who expected this to work but it doesn't, it's possibly because you need to have installed neovim (firstly) and then vscode-neovim extension (secondly) https://marketplace.visualstudio.com/items?itemName=asvetliakov.vscode-neovim

Source: https://github.com/VSCodeVim/Vim/issues/2346

cederlof
  • 7,206
  • 4
  • 45
  • 62