vimrc/vimrc

88 lines
2.1 KiB
VimL

set nocompatible
" Show absolute line number for cursor, and relative for everything else
set number relativenumber
" Split in the right directions
set splitbelow splitright
" incsearch: search for string as you're typing it
" ignorecase + smartcase: do a case-insensitive search by default, but switch
" to case-sensitive if the search string contains capital letters
" nohlsearch: don't highlight search results
set incsearch ignorecase smartcase nohlsearch
" noexpandtab: insert tabs, not spaces
" tabstop=4: display tabs as 4 spaces
set noexpandtab tabstop=4
" Automatically keep the indentation of the previous line
set autoindent
" Create both swap & undo files
set swapfile undofile
" Update screen more often
set updatetime=250
" Center cursor in buffer
set scrolloff=999
" Enable syntax highlighting where possible
syntax enable
" Set space as map key
let mapleader = ' '
" Use jk as escape
inoremap <Esc> <nop>
inoremap jk <Esc>
" Some useful shortcuts
nnoremap <leader>w :w<CR>
nnoremap <leader>q :q<CR>
" Switch between splits
nnoremap <leader>h :wincmd h<CR>
nnoremap <leader>j :wincmd j<CR>
nnoremap <leader>k :wincmd k<CR>
nnoremap <leader>l :wincmd l<CR>
" Create new splits
nnoremap <leader>fh :vsp<CR>:wincmd h<CR>
nnoremap <leader>fj :sp<CR>
nnoremap <leader>fk :sp<CR>:wincmd k<CR>
nnoremap <leader>fl :vsp<CR>
" Resize splits using arrow keys
nnoremap <Up> :resize +5<CR>
nnoremap <Down> :resize -5<CR>
nnoremap <Right> :vertical resize +5<CR>
nnoremap <Left> :vertical resize -5<CR>
nnoremap <S-Up> :resize +1<CR>
nnoremap <S-Down> :resize -1<CR>
nnoremap <S-Right> :vertical resize +1<CR>
nnoremap <S-Left> :vertical resize -1<CR>
" Disable arrow keys in other modes
inoremap <Up> <nop>
inoremap <Down> <nop>
inoremap <Left> <nop>
inoremap <Right> <nop>
vnoremap <Up> <nop>
vnoremap <Down> <nop>
vnoremap <Left> <nop>
vnoremap <Right> <nop>
" Manage tabs
nnoremap <leader>ee :$tabnew<CR>
nnoremap <leader>eL :tabnew<CR>
nnoremap <leader>eH :-tabnew<CR>
nnoremap <leader>ed :tabclose<CR>
nnoremap <leader>el :tabnext<CR>
nnoremap <leader>eh :tabprevious<CR>
" Easier 'go back' binding
nnoremap <leader>a <C-^>
nnoremap gb <C-o>