A vimrc file allows Vim to start with some additional features loaded. There are many, many options to customise Vim's appearance, such as in this vimrc file. However, only a few lines are needed in a vimrc file in order to make a huge difference. This post expands on the previous post, and gives a few more options.
Here is the less minimal vimrc file in a txt file: vimlessmin.txt
Contents of a minimal vimrc file
Copy/paste the following into
syn on set number set tabstop=4 expandtab shiftwidth=4 smarttab set autoindent cindent colo pablo set clipboard=unnamedplus,unnamed,autoselect set undofile set undodir=~/.vimundo set t_Co=256 set ruler
Also, please make the (hidden) vimundo directory:
mkdir -p ~/.vimundo
The purpose of this folder will be explained below.
The new commands explained
If a version of Vim has been installed such that the
+clipboard option is available, the command
allows one to simply copy from a Vim pane using
y, as usual,
but places the text in the system clipboard, so then the text can be pasted outside of Vim in a browser, text file, etc.
This command ensures that the Vim undo history is saved to a file. Why is this useful? By default, if you open a file, e.g.
temp.txt, and edit it, it is possible to go back in time and undo any edits by using the
u command. However, if you then close the file, and then later open it, the edit history would have been erased. This command ensures that the undo history will be persistent; if you close and then later open the file, Vim can access the undo file.
This creates a directory where the Vim undo files will be stored. Any other name instead of
~/.vimundo can be used, but that name is at least explanatory, and the dot makes it hidden (which you may or may not prefer).
This command sets the terminal colours to be 256 colours. This command will probably make no immediately noticeable difference, but if you use Vim in combination with tmux, it may be necessary to have this command - if you use tmux and open Vim, and all the text is grey, then try adding this command to your vimrc.
One of my favourite commands - in the bottom right will be two numbers
Y,X, giving the distance from the top-left. For example, if you put the cursor on the second line, and the the third column, the numbers should be
2,3. Very useful for lining up columns, etc.