Vim Reference
Vim Refrence
This is an article that I wrote to act as a refrence for myself, for using the vim text editor.
Some Brief Background
Vim stands for Vi IMproved. Essentally Vim was made as a fully compatable improved version of vi.
For those that know of them, Yes, vim and vi are really weird text editors.
Especially if you compare them to other more conventional text editors.
They can be hard and clunky to learn because of how different and dense they are.
This difficulty can be partially explained if you go back to the time and systems
that vim’s predicessor vi was made for.
An extreamly breif history and some general information on vi can be found here.
Long story short, vi (and as a result vim) was made during a time when computer mice and even arrow keys on a keyboard were not really a thing.
A resuilt of this is that vim by default uses the h,j,k,l keys to naviagate
Left, down, up and right respectivly.
This method of navigating using the h, j, k, l keys is refered to as the “home row”.
Thankfully nowadays you can use the arrow keys to navigate in vim, but many people will still use that “home row” method of moving around in a file when using vim or vi.
So, why is any of this relivent?
Vim and Vi have been ubiquitus across server systems for many years.
Even today some form of vi and or vim can be found on almost all linux and unix like systems.
As an example: A while back I got a unifi edge router X for my home network system.
To my suprise, this router not only came with a command line interface, but also a basic vi editor too.
Long story short, if it is not windows, and it has some form of a command line interface.
You can probably count that it has some form of vi or vim on it.
Getting vim:
Installing on Linux or Mac:
If you are running Linux or using a Mac, then there is a good chance
that you already have Vim or Vi on your system.
NOTE: If vim is not installed on your linux system by default,
then you should be able to install it using your linux system’s package manager.
Installing on Windows:
If you are on windows and would like to install Vim or give it a try:
you can download and install the graphical version of Vim (gvim) here
At the time of writing this post, the latest windows version of vim is: gvim82
Vim Basic Usage
First lets get some terms out of the way:
Vim has several differentmodessome of them include:
-Normal Mode- This is the default mode. (Enter keyboard shortcuts or commands here.)
-Insert Mode- Used for entering text. (Functions like a fairly normal editor here.)
-Visual Mode- Used for selecting text.
Normal Mode: This is the default mode when you first open up vim.
This mode is used to enter other modes, enter commmads or use keyboard shortcuts.
In short: Enter commands in normal mode by pressing the:key and typing a command.
Insert Mode: This mode is used for actually entering text.
Enter insert mode: by pressing theikey when you are in normal mode.
Exit insert mode: by pressing theEsckey.
Visual Mode- you can select text in this mode,
and then perform operations on the selected text.
Enter visual mode: by pressing thevkey when you are in normal mode.
Exit Visual mode: by pressing theEsckey.
Saving and Quitting:
To launch vim while in a linux command line shell simply run: vim
To edit a file with vim run: vim <filename>
Exiting Vim: From normal mode (this is the default mode when vim is first started)
press the following keys to exit::+q+EnterExiting Vim without saving changes: From normal mode (this is the default mode when vim is first started)
press the following keys to exit::+q+!+EnterSave Changes and Exit Vim: from normal mode, press the following keys:
:+w+q+Enter