Skip to main content

How to install Vim (gvim) step-by-step on Windows PC

how-to-install-gvim-on-windows-pc

How to Install Vim (GVim) on Windows – Step by Step Guide

Vim (Vi Improved) is a fast and powerful text editor. It is widely used by developers and system administrators because of its speed, flexibility, and plugin support. On Windows, you can install both the command-line version (Vim) and the graphical version (GVim).


Steps to Install Vim on Windows

  1. Download Vim: Go to the official Vim website. Under the Windows section, download the latest installer, usually named gvimXX.exe (XX = version number).

    window-gvim-download-guide
  2. Run the Installer: Open the downloaded file and follow the installation steps. The “Typical” option is fine for most users, but you can choose a custom directory if you prefer.

  3. Launch Vim: After installation, you can:

    • Open GVim (graphical version) from the Start Menu.
    • Use vim in Command Prompt or PowerShell (if added to PATH).
  4. Add to PATH (optional): To use Vim from any terminal, add its folder (e.g., C:\Program Files\Vim\vim90) to your system’s PATH environment variable.

  5. Optional Setup: You can pin Vim to your taskbar, set it as the default editor for certain files, and customize it using the _vimrc configuration file.


Youtube Video


Why Use Vim on Windows?

  • Modal Editing: Vim has different modes (Normal, Insert, Visual, Command) for faster editing.
  • Highly Customizable: You can tweak Vim using plugins, themes, and configuration files.
  • Productivity: Powerful keyboard shortcuts let you edit text much faster without using the mouse.

Basic Vim Commands

Modes

Mode Command Explanation
Normal Mode Esc Default mode on startup; used for navigation and issuing operational commands.
Insert Mode i For editing text (enter from Normal mode).
Visual Mode v For selecting text visually (enter from Normal mode).
Command-line Mode : For running commands with a colon prefix (enter from Normal mode).

File Operations

Action Command Explanation
Open/Edit vim filename Opens or creates a file named filename.
Save :w Writes (saves) changes to disk.
Save & Quit :wq Saves changes and exits Vim.
Quit :q Exits (quits) Vim.
Force Quit :q! Quits without saving changes.

Navigation

Action Command Explanation
Move to beginning of line 0 Moves cursor to the start of the current line.
Move to end of line $ Moves cursor to the end of the current line.
Move to first line :1 Jumps to the first line of the file.
Move to last line :$ Jumps to the last line of the file.
Move forward one full screen Ctrl+f Scrolls forward by one full screen.
Move backward one full screen Ctrl+b Scrolls backward by one full screen.

Editing

Action Command Explanation
Enter Insert mode i Switches to Insert mode for typing text.
Delete a line dd Deletes the current line.
Copy a line yy Copies (yanks) the current line.
Paste p Pastes the copied or deleted text after the cursor.
Undo u Undoes the last action.

Searching and Replacing

Action Command Explanation
Search /pattern Finds “pattern” in the text (e.g., /word).
Replace (current line) :s/old/new Replaces first occurrence of "old" with "new" in current line.
Replace in whole file :%s/old/new/g Replaces all occurrences of "old" with "new" in the entire file.

Miscellaneous

Action Command Explanation
Display line numbers :set number Shows line numbers in the editor.
Hide line numbers :set nonumber Hides line numbers in the editor.
Enable syntax highlighting :syntax on Turns on syntax highlighting.
Rename file :f newfilename Renames the current file to newfilename.

Getting Help

Action Command Explanation
View help :help Opens Vim help documentation.
Help for specific command :h command Shows help for a specific Vim command.

Conclusion

Vim is fully functional on Windows, providing robust text editing alongside strong customization and efficiency features. With basic installation steps and the foundational commands above, any new user can begin leveraging Vim for effective coding or text editing tasks on a Windows PC

Comments