Runtime Path

The .vim directory under your home directory is used by Vim as the first place to search for vim scripts after starting up.

It's fine to add your own files, in fact a lot of plugins or plugin managers already do under their own subdirectory. Just be careful not to name your files or subdirectories anything that is already used by Vim. Take a look at the 'runtimepath' documentation for a list.

Vim Commands
# Search and replace text

Visual block mode can be used to comment blocks of code

press Esc (to leave editing or other mode)
hit ctrl + v (visual block mode)
use the up/down arrow keys to select lines you want (it won't highlight everything - it's OK!)
Shift + i (capital I)
insert the text you want, i.e. %
press Esc Esc.
Vim History

less .viminfo to view recent history in vim. could possibly recover lost files / information if needed.

Custom .vimrc

Comments in .vimrc is as follows -

" Comments to describe what the line of code below does
"" Actual working code for the .vimrc file - could be uncommented and ran

If ~/.vimrc does not exist in your home directory, create it, and customize it to suit your needs. For example, the following .vimrc will set your tab size to 2 from the default 4, and convert your tabs to spaces automatically. This is useful when sharing code, as things are more compact and using spaces is less ambiguous than tab sizes across platforms.

set tabstop=2 shiftwidth=2 expandtab autoindent mouse=a

Here, tabstop is the tab size setting, measured in spaces. shiftwidth allows vim to compensate according to our tab settings when automatically indenting, etc. expandtab converts our tab size setting into actual spaces. set autoindent will set vim to automatically indent to our current depth when in insert mode and moving to a new line by pressing enter. This will not insert spaces unless text is input. mouse=a enables mouse interaction with split windows, when supported.

" Comments to describe what the line of code below does
"" Actual working code for the .vimrc file - could be uncommented and ran
Split Windows in Vim

Run the commands below to split windows while within a Vim session -

:split /path/to/file # To split horizontally
:vsplit /path/to/file # To split vertically


:sp /path/to/file # To split horizontally
:vs /path/to/file # To split vertically

:open /path/to/file # To open a file within the active tab

:retab # To resize tabs in this session to your .vimrc configuration

# Split horizontal windows from bash
vim -o file.txt file2.txt file3.txt 

# Split vertical windows from bash
vim -O file.txt file2.txt file3.txt

# Tabbed windows from bash
vim -p file.txt file2.txt file3.txt

Window Navigation

Use Ctrl-w <Arrow Keys> or Ctrl-w <h j k l> to move between split windows.
Use Ctrl-w w to move to the next window, Ctrl-w W to move to the previous.
Use Ctrl-w s to split active window horizontally, Ctrl-w v to split active window vertically.
Ctrl-w c, :q, :close, or :clo to close the active window.
Close all other windows with Ctrl-w o, :only, or :on.

Tab Navigation

Use Ctrl-w PgUp and Ctrl-w PgDwn to move between tabs within vim

Code Completion in Vim

Check out for code completion. Instructions are within the README there.
This is dependent on the clang package / library. Install it using your package manager if you receive errors.
Be sure to edit your .vimrc to use clang_complete - instructions on the GitHub

Check out Pathogen plugin manager for Vim, allows for easy installation of useful plugins via git clone into a specified directory..
To uninstall Pathogen -

  • delete ~/.vim/autoload/pathogen.vim,

  • delete the lines you have added to ~/.vimrc.

If you use code-completion, you'll probably miss the tab function that usually brought up a context menu with code snippets. To use something similar, check out
This requires Pathogen.

A .vimrc running all of these modifications might look like the below -

" Set tabwidth=2, adjust Vim shiftwidth to the same
set tabstop=2 shiftwidth=2 

" expandtab inserts spaces instead of tabs
set expandtab 

" autindent inserts the next line at your current depth
set autoindent 

" mouse=a allows for mouse interaction with vim when supported
set mouse=a

" Enable Syntax Highlighting in Vim
syntax on

" Enable Pathogen plugin manager
execute pathogen#infect()
filetype plugin indent on

" Enable clang_complete plugin for vim
" Requires clang to be installed
" Path to library may change
let g:clang_library_path='/usr/lib64/'