Your Personal Configuration and Getting Help

Create Your Perfect VIM Environment and Never Feel Lost Again

Alt text

You’ve mastered VIM’s commands, but every time you log into a new server, you’re back to default settings—no line numbers, case-sensitive search, no syntax highlighting. Meanwhile, you occasionally wonder “how do I do X again?” and wish VIM had built-in help. It does, and it’s comprehensive.

This lesson teaches you to make VIM truly yours: create a configuration file that sets your preferences automatically, access VIM’s massive help system whenever you need it, and use command completion to discover features you didn’t know existed.

These aren’t just convenience features—they’re what separate someone who uses VIM from someone who’s made VIM theirs.

Understanding VIM’s Help System

VIM has one of the most comprehensive help systems of any text editor. Every command, option, and feature is documented in detail. Learning to navigate this help will make you self-sufficient.

Opening Help: :help

The simplest way to access help:

:help

Or press F1 (if your terminal supports it).

Try it now:

Open VIM:

vim

Type :help and press ENTER.

A help window opens at the top of your screen. You’re looking at VIM’s main help page with links to various topics.

What you see:

In the help window, you can:

Try this:

  1. With help open, navigate to |quickref| (using j or searching: /quickref)
  2. Press Ctrl-] with cursor on quickref
  3. You jump to a quick reference page showing all commands
  4. Press Ctrl-O to go back
  5. Type :q to close help window

Getting Help on Specific Commands: :help command

This is the most powerful way to use help. Whenever you want to know about a command:

:help dd
:help yy
:help :substitute
:help /

Examples:

Get help on the delete line command:

:help dd

Learn about substitution:

:help :substitute

Understand search:

:help /

Try it:

  1. Type :help yy and press ENTER
  2. Read about the yank command
  3. Type :q to close help

Help for Settings: :help 'option'

For settings, use quotes:

:help 'ignorecase'
:help 'number'
:help 'hlsearch'

Try it:

:help 'incsearch'

Learn exactly what incremental search does and all its nuances.

Help for Modes

Get help on modes:

:help insert-mode
:help normal-mode
:help visual-mode

The Help Tag System

VIM’s help uses tags. When you see text like |this|, it’s a link to a help tag. You can jump directly to any tag:

:help tag-name

For example:

:help motion.txt
:help usr_01.txt
:help pattern-searches

Searching Help

You can search within help like any other file:

  1. Open help: :help
  2. Search: /word
  3. Navigate matches: n and N

Or search all help files:

:helpgrep search_term

This searches through all help files and creates a list of matches you can navigate through.

Command 2: Window Management - Ctrl-W Ctrl-W

When help opens, it creates a new window split. You can have multiple windows open in VIM and switch between them.

Switch Windows: Ctrl-W Ctrl-W

Press Ctrl-W twice (hold Ctrl, press W, press W again) to cycle between windows.

Try it:

  1. Type :help to open help
  2. Now you have two windows (help on top, your file below)
  3. Press Ctrl-W Ctrl-W
  4. Your cursor jumps to the other window
  5. Press Ctrl-W Ctrl-W again
  6. Back to the first window

Shorter notation: Many people write this as Ctrl-W Ctrl-W but you can also press Ctrl-W then release and press w (lowercase). Both work.

More Window Commands (Preview)

We’ll cover these in detail in future lessons, but here are the basics:

Close Help Window: :q

When you’re in the help window, type :q to close it and return to your file.

Workflow:

  1. Open help: :help command
  2. Read help (navigate with hjkl, search with /, follow links with Ctrl-])
  3. Switch to your file if needed: Ctrl-W Ctrl-W
  4. Close help: switch to help window and :q, or just :q if you’re already there

Command 3: The vimrc Configuration File

Every time you start VIM, it looks for a configuration file called .vimrc (in your home directory on Unix systems). This file contains VIM commands that run automatically at startup.

What is .vimrc?

The .vimrc file is a plain text file containing VIM commands (without the : prefix). It’s where you put:

Creating Your .vimrc

Let’s create a basic .vimrc with useful settings for bioinformatics work:

vim ~/.vimrc

Press i to enter Insert Mode, then type or paste:

" Basic VIM Configuration for Bioinformatics
" Comments start with a double-quote

" ============================================================
" DISPLAY SETTINGS
" ============================================================

" Show line numbers
set number

" Highlight the current line
set cursorline

" Show matching brackets when cursor is over them
set showmatch

" Always show current position
set ruler

" Show command in bottom bar
set showcmd

" ============================================================
" SEARCH SETTINGS
" ============================================================

" Case-insensitive searching
set ignorecase

" But case-sensitive if search contains uppercase
set smartcase

" Highlight search results
set hlsearch

" Search as you type (incremental search)
set incsearch

" ============================================================
" INDENTATION SETTINGS
" ============================================================

" Use spaces instead of tabs
set expandtab

" Number of spaces for each tab
set tabstop=4

" Number of spaces for indentation
set shiftwidth=4

" Number of spaces for <Tab> key in insert mode
set softtabstop=4

" Copy indent from current line when starting new line
set autoindent

" ============================================================
" EDITING BEHAVIOR
" ============================================================

" Allow backspace over everything in insert mode
set backspace=indent,eol,start

" Don't wrap lines
set nowrap

" Show line breaks visually without inserting line breaks
set linebreak

" Keep 5 lines visible above/below cursor when scrolling
set scrolloff=5

" Enable mouse support (all modes)
set mouse=a

" ============================================================
" FILE HANDLING
" ============================================================

" Enable syntax highlighting
syntax enable

" Detect file types
filetype plugin indent on

" Don't create backup files
set nobackup
set nowritebackup

" Don't create swap files
set noswapfile

" Auto-read file if changed outside VIM
set autoread

" ============================================================
" INTERFACE IMPROVEMENTS
" ============================================================

" Show partial commands in the last line
set showcmd

" Show current mode
set showmode

" Better command-line completion
set wildmenu
set wildmode=longest:full,full

" Ignore case in command-line completion
set wildignorecase

" ============================================================
" CUSTOM KEY MAPPINGS (optional - uncomment to use)
" ============================================================

" Clear search highlighting with Esc-Esc
" nnoremap <Esc><Esc> :nohlsearch<CR>

" Save file with Ctrl-S (in normal mode)
" nnoremap <C-s> :w<CR>

" Easier window navigation
" nnoremap <C-h> <C-w>h
" nnoremap <C-j> <C-w>j
" nnoremap <C-k> <C-w>k
" nnoremap <C-l> <C-w>l

" ============================================================
" BIOINFORMATICS-SPECIFIC SETTINGS
" ============================================================

" Recognize common bioinformatics file types
autocmd BufRead,BufNewFile *.fasta,*.fa set filetype=fasta
autocmd BufRead,BufNewFile *.fastq,*.fq set filetype=fastq
autocmd BufRead,BufNewFile *.vcf set filetype=vcf
autocmd BufRead,BufNewFile *.sam,*.bam set filetype=sam
autocmd BufRead,BufNewFile *.gff,*.gtf set filetype=gff

" Python settings (for bioinformatics scripts)
autocmd FileType python set expandtab tabstop=4 shiftwidth=4

" R settings (for statistical analysis)
autocmd FileType r set expandtab tabstop=2 shiftwidth=2

" Shell script settings
autocmd FileType sh set expandtab tabstop=2 shiftwidth=2

" YAML settings (for Snakemake, configs)
autocmd FileType yaml set expandtab tabstop=2 shiftwidth=2

Press ESC, type :wq, press ENTER.

Understanding .vimrc Syntax

Comments: Lines starting with " are comments

Settings: Just the command without the : prefix

set number          " Instead of :set number

Multiple settings on one line:

set number ruler showcmd

Unsetting options:

set nonumber        " Turn off line numbers
set nowrap          " Don't wrap lines

Testing Your .vimrc

Close VIM completely and open it again:

vim test.txt

You should now see:

Try searching for something—results are highlighted because hlsearch is set.

Common .vimrc Settings Explained

Display settings:

Search settings:

Indentation:

Quality of life:

Portable Configuration

The beauty of .vimrc is portability. Copy it to any server:

scp ~/.vimrc username@server.edu:~/

Now VIM behaves identically on that server.

Or keep it in a Git repository:

git clone https://github.com/yourusername/dotfiles.git
ln -s ~/dotfiles/vimrc ~/.vimrc

One configuration, everywhere you work.

Command 4: Command Completion - Ctrl-D and Tab

VIM has command-line completion that helps you discover and use commands.

See All Completions: Ctrl-D

When typing a command, press Ctrl-D to see all possible completions.

Try it:

  1. Type :set (with a space after “set”)
  2. Press Ctrl-D
  3. VIM shows a list of all available settings

Another example:

  1. Type :help m (partial command)
  2. Press Ctrl-D
  3. See all help topics starting with ‘m’

For file operations:

  1. Type :e (the edit command with a space)
  2. Press Ctrl-D
  3. See all files in current directory

Cycle Through Completions: Tab

Press Tab to cycle through completions one at a time.

Try it:

  1. Type :set nu (incomplete)
  2. Press Tab
  3. VIM completes to :set number
  4. Press Tab again
  5. Cycles to other options starting with “nu”

For settings:

  1. Type :set i
  2. Press Tab repeatedly
  3. Cycles through: ignorecase, incsearch, indent, etc.

For files:

  1. Type :e scr
  2. Press Tab
  3. If you have a file starting with “scr”, it completes
  4. Press Tab again to cycle to next match

Completion with Wildmenu

If you have set wildmenu in your .vimrc (we added it), completion is even better:

  1. Type :color (space after)
  2. Press Tab
  3. A menu appears showing all color schemes
  4. Press Tab to cycle through them
  5. Press Enter to select one

This works for any command with multiple options.

Discovering Commands

Use completion to discover what’s available:

All commands starting with ‘s’:

:s[Ctrl-D]

All help topics about ‘search’:

:help search[Ctrl-D]

All settings:

:set [Ctrl-D]

This is incredibly useful when you know approximately what you want but not the exact command.

Practical Workflows

Workflow 1: Learning New Commands

You want to learn about text objects:

  1. Type :help text-objects and press Enter
  2. Read the help
  3. See a command you want to try: ciw (change inner word)
  4. Press Ctrl-W Ctrl-W to switch to your file
  5. Try the command on some text
  6. Switch back to help: Ctrl-W Ctrl-W
  7. Continue reading
  8. Close help: :q

Workflow 2: Setting Up a New Server

You’ve logged into a new HPC cluster:

  1. Copy your .vimrc: scp ~/.vimrc username@newserver:~/
  2. SSH into the server
  3. Open VIM: vim analysis.sh
  4. All your settings are active automatically
  5. Start working with your familiar environment

Workflow 3: Finding the Right Setting

You want to change something but don’t know the exact setting name:

  1. Type :set
  2. Press Ctrl-D to see all options
  3. Search through the list
  4. Or type partial name: :set wrap
  5. Press Tab to complete
  6. Check current value: :set wrap?
  7. Change it: :set nowrap

Workflow 4: Exploring Help

You heard about “registers” but don’t know what they are:

  1. Type :help registers
  2. Read the comprehensive documentation
  3. Follow links to related topics: cursor on |link|, press Ctrl-]
  4. Go back: Ctrl-O
  5. Search within help: /yank
  6. Close when done: :q

Customizing Your .vimrc Over Time

Your .vimrc should evolve with your needs. Here’s how to improve it:

Testing Settings Before Adding

  1. Try a setting in VIM: :set number
  2. If you like it, add to .vimrc
  3. Reload .vimrc: :source ~/.vimrc (or restart VIM)

Common Additions

Color scheme:

colorscheme desert

See available schemes: :colorscheme then Tab through options.

Status line:

set laststatus=2  " Always show status line
set statusline=%F%m%r%h%w\ [%l,%c]\ [%L]

Shows filename, line/column, total lines.

Persistent undo:

set undofile
set undodir=~/.vim/undodir

Remembers undo history between sessions.

Spell checking:

set spell spelllang=en_us

Enable with :set spell, disable with :set nospell.

Organizing Your .vimrc

Keep it organized with sections (like we did in the example):

Add comments explaining why you set things:

" Case-insensitive search - important for gene names
set ignorecase

Advanced .vimrc Features (Preview)

Your .vimrc can do much more (topics for future lessons):

Custom key mappings:

" Press ,w to save file
nnoremap ,w :w<CR>

" Press ,q to quit
nnoremap ,q :q<CR>

Abbreviations:

" Type 'fastqc' and get full command
iabbrev fastqc fastqc --threads 8 -o qc_results/

Functions:

" Custom function to insert date
function! InsertDate()
    r !date +\%Y-\%m-\%d
endfunction

Conditional settings:

" Different settings for different file types
if has('python')
    set expandtab
endif

We’ll cover these in advanced lessons.

Practice Exercises

Exercise 1: Use Help System

  1. Open VIM: vim
  2. Get help on the yank command: :help yy
  3. Follow a link: position cursor on |y| and press Ctrl-]
  4. Go back: Ctrl-O
  5. Search for “motion”: /motion
  6. Close help: :q

Exercise 2: Navigate Help Windows

  1. Open a file: vim test.txt
  2. Open help: :help dd
  3. Switch to your file: Ctrl-W Ctrl-W
  4. Switch back to help: Ctrl-W Ctrl-W
  5. Close help: :q
  6. Continue editing

Exercise 3: Explore Command Completion

  1. Type :set
  2. Press Ctrl-D to see all settings
  3. Type :set nu
  4. Press Tab to complete
  5. Press Enter to execute
  6. Check result: :set number?

Exercise 4: Customize .vimrc

  1. Open .vimrc: vim ~/.vimrc
  2. Add a new setting: set relativenumber
  3. Save: :wq
  4. Open VIM again: vim test.txt
  5. Verify the setting works (line numbers are now relative)
  6. If you don’t like it, remove it from .vimrc

Exercise 5: Help for Settings

  1. Type :help 'hlsearch'
  2. Read about highlighting search results
  3. Note the single quotes in the help command
  4. Close help: :q
  5. Enable the setting: :set hlsearch
  6. Test by searching: /test

Common .vimrc Mistakes

Wrong location: .vimrc must be in your home directory (~/.vimrc)

Including the colon: Commands in .vimrc don’t use : prefix

" Wrong:
:set number

" Right:
set number

Syntax errors: VIM will show error on startup if .vimrc has problems

File permissions: Make sure .vimrc is readable:

chmod 644 ~/.vimrc

Quick Reference

HELP SYSTEM:
  :help                - Open main help
  :help cmd            - Help for specific command
  :help 'option'       - Help for setting (use quotes)
  Ctrl-]               - Follow help link
  Ctrl-O               - Go back in help
  :q                   - Close help window
  
WINDOWS:
  Ctrl-W Ctrl-W        - Switch between windows
  Ctrl-W q             - Close current window
  
COMMAND COMPLETION:
  Ctrl-D               - Show all completions
  Tab                  - Cycle through completions
  
VIMRC:
  ~/.vimrc             - Configuration file location
  :source ~/.vimrc     - Reload configuration
  " comment            - Comment syntax
  set option           - Set an option (no colon)

What You’ve Mastered

You now know how to:

Combined with all previous commands, you’re now a competent VIM user with a customized setup.

What’s Next

You’ve completed the essential VIM curriculum! You can now:

Optional advanced topics for future learning:

But you don’t need these to be productive. With what you’ve learned, you can efficiently edit any file on any remote server.

Your Action Items

  1. Create your .vimrc using the template provided
  2. Copy it to your HPC clusters where you work
  3. Practice using help when you forget a command
  4. Customize gradually as you discover preferences
  5. Keep learning by exploring help topics

The Journey Complete

You started unable to exit VIM. Now you have:

VIM is no longer a mysterious tool—it’s your efficient, portable, powerful text editing environment that works identically on every system you touch.

Use it daily. Keep your .vimrc updated. Explore help when curious. VIM will continue revealing its power as your skills grow.

Welcome to efficient text editing. You’ve earned your VIM mastery.


This completes the VIM Essentials series. You’re now equipped to edit configuration files, scripts, and data efficiently on any bioinformatics system. Your .vimrc travels with you, and VIM’s help is always there when you need it. Happy editing!

← Previous Next →