Text Editing

Vim has many tools for editing large text files. Some examples below.


These commands can be used directly in vim, or bound to a key within a custom ~/.vimrc

Search / Replace

To search and replace text within an active vim session

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

Visual Block Mode

Inserting text at the beginning of multiple lines

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.

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.