My .vimrc

My .vimrc

.vimrc is the file where you can configure how you want vim to run.

In your .vimrc file you can specify which vim plugins you use, which colorscheme, custom keybindings and various other neat configurations to make your vim experience the best it can be!

Since everyone has their own way of configuring the way they use vim, I thought I’d share mine with you:

.vimrc code

" Ensure vim-plug is installed
if empty(glob('~/.vim/autoload/plug.vim'))
  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC

" vim-plug plugins
call plug#begin()
        Plug 'scrooloose/nerdtree'      " A built-in file browser!
        Plug 'tpope/vim-surround'       " Allows you to easily change surrounding characters
        Plug 'vim-airline/vim-airline'  " A very nice status line plugin!
        Plug 'vim-airline/vim-airline-themes'   " Themes for the very nice status line!
        Plug 'morhetz/gruvbox'          " One of my favorite color schemes!
call plug#end()

" Adds the line numbers to the left side and the ability to scroll through command options
set number
set wildmenu

" I like the gruvbox color theme in dark mode. The airline plugin supports gruvbox as well!
color gruvbox
set bg=dark
let g:rehash256 = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline_powerline_fonts=1
let g:airline_theme='gruvbox'

" I use vim inside of Windows Terminal, and this lets me select/point with my mouse
" and scroll up and down the page with my scroll wheel.
set mouse=a
map <ScrollWheelUp> <C-Y>
map <ScrollWheelDown> <C-E>

" Automatically close brackets/parenthesis
inoremap " ""<left>
inoremap ' ''<left>
inoremap ( ()<left>
inoremap [ []<left>
inoremap { {}<left>
inoremap {<CR> {<CR>}<ESC>O
inoremap {;<CR> {<CR>};<ESC>O

" Press F9 to save and run python code
autocmd FileType python map <buffer> <F9> :w<CR>:exec '!python3' shellescape(@%, 1)<CR>
autocmd FileType python imap <buffer> <F9> <esc>:w<CR>:exec '!python3' shellescape(@%, 1)<CR>)'')''"}}}}}}]]))'''""""""''"")"''"''"''"''"'')"''))"