Skip to main content

VIM from Windows Command Prompt

Tags

Vim Logo

In my quest to become more familiar with using the Windows Command Prompt I have been experimenting with basic text editing and file management from the command prompt to cut the distraction between switching from an IDE to the terminal all the time.  I found that working with a text editor like Sublime Text or working with an IDE like Brackets you often need to switch back and forth between your terminal and editor, well what if I could perform text editing in the command prompt just like I do with Vim or Nano in Linux?  This would enable me setup my Gulp files, run my Node Package Manager commands and exit the command prompt for a good deal of time before returning.

 

Getting started on the command prompt is very easy, it is the same concept as the Unix terminal except the folder structure is different and some of the commands are different. Here is a crash course in the command prompt to get your started:

# Change directory from anywhere to your htdocs folder
> cd /xampp/htdocs
 
#Create a temp directory
> mkdir temp
 
# Move the temp directory to the permanent directory
>  move temp permanent
 
# Remove the permanent folder and all of its files and sub-directories
>  RMDIR permanent /s /q
 
# Create a blank file
> type NUL > myEmptyFile
 
#Create a file with a bit of text inside of it
> echo { “devDependencies”:{}} > package.json
 
#Delete a file 
> del package.json

All of this was not that hard to get started, very straight forward and to the point.  Except when it came time to edit my text files I was creating.  That caused a bit of an issues because Windows does not have a default text editor out of box in the command prompt.  I had to look elsewhere to find one, and my search brought me to Vim.  Vim is a lot like Vi from the Unix world except it has a bit more to offer, such as syntax highlighting and plugin capability.  After installing Vim for Windows, found here, I was able to use the vim command to open and edit files with the same commands that you would use for Vi.

# Open a file
vim package.json
 
#Once the file is open, hit the “I” key to put Vim in insert mode and start editing
#Once you are done editing, press esc -> : -> w -> q and enter to save your work

Let me know if anyone has any questions.

Member for

3 years 5 months
Matt Eaton

Long time mobile team lead with a love for network engineering, security, IoT, oss, writing, wireless, and mobile.  Avid runner and determined health nut living in the greater Chicagoland area.

Comments

I have installed VIM's PATH into the Environmental Variables --> system variables (exactly as I did for Python- when I kept trying to open python through the CMD window and would get the message "Python is not recognized as an internal or external command, operable proggram or batch file.) I still can't open VIM however.

With python, It won't open if I type the full name out. It only opens in the CMD by typing "PY" (no quotes). Is there a different command for opening VIM? I've tried VIM8 , VIM-8 , VIM8.1, V, etc.

Any comments appreciated.

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.