sudoedit.com!

My Vim Configuration

I've been putting together a vimrc file that I can use while writing for a good long while now.

I like having the spacebar set as my leader key instead of the default \ which in my opinion is kind of a pain in the ass to reach. I know a lot of people like to use the , for leader but I've never been able to get used to it.

I use a few plugins for fuzzy finding and markdown support, and I use vim-plug as my plugin manager, so if you copy and paste my vimrc you'll need to make sure you've got that installed before this will work.

Plug 'godlygeek/tabular'
Plug 'preservim/vim-markdown'
Plug 'mileszs/ack.vim'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'

Speaking of which I hear the latest version of vim will manage its own plugins so I should probably take a look at how that's done.

The vim-markdown plugin is nice but sometimes the folding can be a little erratic, so at the moment I default to disabling the folding.

This vimrc is an amalgamation of things I've picked up on the interwebs but I want to point a few sites that have been particularly helpful.

vim is my comfort zone

Over the years I've bounced around between different text editors but I keep coming back to vim because I've been using it for so long that everything else ends up feeling like it's getting my way.

My .vimrc file

call plug#begin()
Plug 'godlygeek/tabular'
Plug 'preservim/vim-markdown'
Plug 'mileszs/ack.vim'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
call plug#end()

" PLUGIN CONFIGURATION
let g:vim_markdown_toc_autofit = 1
let g:vim_markdown_frontmatter = 1
set nofoldenable

" VIM config
filetype plugin on
syntax on
set autoindent
set expandtab
set gfn=Monaco:h12
set ignorecase
set incsearch
set linebreak
set nocompatible
set number
set rtp+=/usr/bin/fzf
set shiftwidth=3
set smarttab
set softtabstop=3
set spelllang=en_us
set tags+=./tags;,tags
set t_Co=256
set textwidth=120
set title
set wildmenu
set wildmode=list:longest,full
set wrap
colorscheme slate

" Netrw settings
let g:netrw_liststyle = 3
let g:netrw_banner = 0
let g:netrw_browse_split = 3
let g:netrw_winsize = 20


noremap <SPACE> <Nop>
let mapleader = " "
" Clear search history at launch
let @/ = ""

" Work with Files
"" Search for files
nnoremap <leader>ff :Files<cr>
"" Search for strings
nnoremap <leader>fg :Rg<cr>
"" Search tags
nnoremap <leader>ft :Tags<cr>
" Save buffer
nnoremap <leader>w :w<cr>
"" Move buffers
nnoremap <leader>bn :bn<cr>
nnoremap <leader>bp :bp<cr>
"" Move windows
nnoremap <leader>sw :wincmd w<cr>
"" Surround word with single quotes
nnoremap <leader>' ea'<esc>hbi'<esc>
"" Surround word with double quotes
nnoremap <leader>" ea"<esc>hbi"<esc>
"" Surround word with Parenthesis
nnoremap <leader>( ea)<esc>hbi(<esc>

" Custom key mapping
"" normal mode
nnoremap <C-n> :Vex<CR>
""" Clear search hightlighting by hitting enter twice
nnoremap <CR> :noh<CR><CR>
""" Move line down
nnoremap <c-j> ddp
""" Move line down
nnoremap <c-k> ddkP
" Generate ctags
nnoremap <leader>tt :!ctags -R . <CR>
" set spell on
nnoremap <leader>ssy :set spell<CR>
" set spell off
nnoremap <leader>ssn :set nospell<CR>
" select word and up case it
nnoremap <leader>vuc viw U<esc>
" select word and down case it
nnoremap <leader>vdc viw u<esc>
" redo
nnoremap <leader>U <c-r>

"" insert mode
inoremap jk <esc>

" NOTES
" Go to notes and set working directory to my notes
" NOTES_DIR and TODAY defined in shell rc file
nnoremap <leader>nj :e $NOTES_DIR/$YEAR/$TODAY.jrnl.md<CR>:cd $NOTES_DIR<CR>
nnoremap <leader>nt :e $NOTES_DIR/todo.md<CR>:cd $NOTES_DIR<CR>
nnoremap <leader>ns :e $NOTES_DIR/scratchpad.md<CR>:cd $NOTES_DIR<CR>

" Auto Commands
" Remove any trailing whitespace in the file
autocmd BufRead,BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif

Thanks for reading.

If you've got any other suggestions or want to let me know how awesome vim is send me an email.