Software

VIMRC File Configuration

I started using Vim in earnest about two years ago, and it has become my main text editor since. But before you dive in you should know the learning curve is steep but it comes with powerful capabilities. I won’t go into all the pros and cons but I do want to share how I have set up my vimrc file. This is a configuration file that you can add desired startup options to that can fit your preferences.

I decided to modify my Vim configuration with a few things in mind, firstly to enable a file explorer that can be used to easily navigate and open text files as I am coding and to set my formatting style.

syntax on
filetype plugin indent on
set clipboard=unnamed
let g:netrw_banner = 0
let g:netrw_liststyle = 3
let g:netrw_browse_split = 3
let g:netrw_altv = 1
let g:netrw_winsize = 25
set backspace=indent,eol,start
set showmode
set tabstop=2
set shiftwidth=2
set expandtab
set hlsearch
set nu
inoremap jk <esc>
augroup ProjectDrawer
  autocmd!
  autocmd VimEnter * :tabnew
  autocmd VimEnter * :Explore
  autocmd VimEnter * :tabmove 0
  autocmd VimEnter * :tabn
augroup END

The first section sets up netwr file explorer, this allows you to navigate directories and open files all while staying inside Vim.

The set functions set various parameters in the text editor like the tab width and replace tabs with the number of spaces. These are more personal preferences based on how you like your text formatted.

The inoremap is one of the more fun functions that allows you to remap keyboard entries to do other things in vim. In this case, I am using it to map “jk” which used individually are navigation keys but when quickly typed one after the other send the “escape” key. This allows me to exit insert mode without leaving the home row!

The last section sets up vim to place the netrw in a new tab and move that tab all the way to the left-most index. It then moves the active window back to either a new blank widow or the file that you wanted to open. This is all hidden from the user when you start Vim but allows you to always have the file navigation available when you need it.

Optional

There are tons of installable plugins that make vim more powerful depending on your use case along with several “package managers” that help you install and launch them.

I use pathogen to enable the AirLine plugin that enables powerline fonts to be used in the design elements of vim, giving a more consistent feel to my terminal now that I am using powerlevel10k to augment my shell.

Pathogen install

https://github.com/tpope/vim-pathogen

Add this to the top of your .vimrc file to enable pathogen

call pathogen#incubate()
call pathogen#helptags()
execute pathogen#infect()

Install airline for more visual configurations, basically powerlevel10k for vim!

https://github.com/vim-airline/vim-airline

Demo Time

Open Vim

vim

Editing Text

Use all the normal Vim commands to edit text

Changing Tabs

gt moves one tab to the right
gT move one tab to the left

Navigating Directories

Use arrows or Vim “hjkl” to navigate up and down files, use Enter to open or close folders

Open Files

When you are on a file Enter will open that file into a new tab