'vim' is not recognized as an internal or external command

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
3 min

banner

# 'vim' is not recognized as an internal or external command

The error "'vim' is not recognized as an internal or external command, operable program or batch file" occurs when we use the vim command without having vim installed or added to the PATH environment variable.

To solve the error, install vim and make sure it's correctly configured.

vim is not recognized as internal or external command

  1. Open the vim downloads page and click on "standard self-installing executable" in the "MS-Windows" section.

click standard self installing executable

  1. Start the installer and click "Next".

start vim installer click next

  1. On the next screen, accept the terms of the License Agreement and click "Next".

accept vim license agreement

  1. On the next screen, leave the default Components selected and click "Next".

vim choose components

  1. On the next screen, leave the default vimrc settings selected and click "Next".

choose vimrc settings

  1. Make note of the default "Destination Folder" for where vim will be installed and click "Install".

vim choose install location

  1. Close your CMD (Command Prompt) shell and reopen it.

  2. Try running the vim command.

cmd
vim example.txt

vim create file

You can press i to enter insert mode and start typing.

Once you're done, press Esc and type :wq (write, quit) to save the changes and exit.

vim edit file

If you still get the error, you have to add vim to your PATH environment variable.
  1. Click on the Search bar and type "environment variables".
  2. Click on "Edit the system environment variables".

edit system environment variables

  1. Click on the "Environment Variables" button.

click environment variables

  1. In the "System variables" section, select the "Path" variable and click "Edit".

select path and click edit

  1. If you don't see the PATH to vim in the list, e.g. C:\Program Files (x86)\Vim\vim90, click on "New" and then "Browse".

    Note that your version of vim might be different, so unless you know the path, use the "Browse" function.

    We have to locate the directory that contains the executable file, e.g. vim.exe.

click new browse

  1. Click on "This PC" > "Local Disk (C:)" > "Program Files (x86)" > "Vim" > "Vim90" and then click "OK".

Note that your version of vim might be different, e.g. Vim95.

  1. Click "OK" twice to confirm adding the path.

  2. Close your Command prompt application and then reopen it.

Note that you must restart your Command prompt shell for the changes to take effect.

You might also have to restart your PC, but that's not always necessary.

Now you should be able to run the vim command.

cmd
vim example.txt

vim create file

You can press i to enter insert mode and start typing.

Once you're done, press Esc and type :wq (write, quit) to save the changes and exit.

vim edit file

I've also written an article on:

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.