aboutsummaryrefslogtreecommitdiff
path: root/.vimrc
diff options
context:
space:
mode:
Diffstat (limited to '.vimrc')
-rw-r--r--.vimrc82
1 files changed, 55 insertions, 27 deletions
diff --git a/.vimrc b/.vimrc
index 6b8dd5b..6ff14c7 100644
--- a/.vimrc
+++ b/.vimrc
@@ -2,24 +2,25 @@
" vimrc "
""""""""""
-" source pluggins
+" load pluggins
source $HOME/dotfiles/.pluggins.vim
-
" common
let mapleader = ' ' " set leader key to space
-syntax enable " enable syntax
-set hidden " keep change in buffer when quitting window
-set noswapfile " disable swap files
+let maplocalleader = '-' " set file local leader key to backslash
set nocompatible " not compatible with vi
-filetype plugin indent on " allow to add specific rules for certain type of file
-set number relativenumber " line number relative to cursor
+set number " line number
+set relativenumber " line number relative to cursor
+set numberwidth=1 " line numbers gutter autowidth
set cursorline " highlight current line
set noshowmatch " dont jump to pair bracket
set autoread " reload files when changes happen outside vim
+set hidden " keep change in buffer when quitting window
+set noswapfile " disable swap files
set scrolloff=2 " line padding when scrolling
-set encoding=utf-8 " utf-8 encoding
set textwidth=89 " when line wrap occurs
+set encoding=utf-8 " utf-8 encoding
+filetype plugin indent on " allow to add specific rules for certain type of file
" browse list with tab
set wildmode=longest,list,full
@@ -31,18 +32,6 @@ set splitbelow
set splitright
set fcs+=vert:\ " no split separator
-" split navigation
-nnoremap <C-J> <C-W><C-J>
-nnoremap <C-K> <C-W><C-K>
-nnoremap <C-L> <C-W><C-L>
-nnoremap <C-H> <C-W><C-H>
-
-" spit resizing
-nnoremap zh <C-W>>
-nnoremap zl <C-W><
-nnoremap zj <C-W>-
-nnoremap zk <C-W>+
-
" tab
set expandtab " tab to space
set tabstop=4 " tab size
@@ -62,6 +51,8 @@ set laststatus=2 " always a statusline (all window)
set showcmd " show current partial command in the bottom right
set noshowmode " dont show current mode (i.e --INSERT--)
+" fold
+set foldmethod=indent " create fold based on the text indent
" ctrlp pluggin
" directory to ignore when searching in file tree
@@ -75,24 +66,61 @@ colorscheme onedark
let g:lightline = {}
let g:lightline.colorscheme = 'one' " lightline theme to onedark
-" mappings
+""""""""""""
+" mappings "
+""""""""""""
+
+" split navigation
+nnoremap <C-J> <C-W><C-J>
+nnoremap <C-K> <C-W><C-K>
+nnoremap <C-L> <C-W><C-L>
+nnoremap <C-H> <C-W><C-H>
+
" 'Y' yank to the end of the line
noremap Y y$
-
" solves annoying delay went exiting insert mode
-imap <ESC> <C-C>
-" jj or kk to exit insert mode
-imap jj <ESC>
-imap kk <ESC>
+inoremap <ESC> <C-C>
+" kj to exit insert mode
+inoremap kj <ESC>
" remove visual mode keybinding
-map Q <ESC>
+noremap Q <nop>
+" remove command line window keybinding
+noremap q: <nop>
" incsearch
map / <Plug>(incsearch-forward)
map ? <Plug>(incsearch-backward)
map g/ <Plug>(incsearch-stay)
+" move line up and down
+nnoremap _ ddkP
+nnoremap + ddp
+" long move up/down
+nnoremap ( 10k
+nnoremap ) 10j
+" tag nagigation
+nnoremap <leader>] <C-]>
+nnoremap <leader>t <C-t>
+" buffer navigation
+nnoremap <leader>n :bn<CR>
+nnoremap <leader>p :bp<CR>
+nnoremap <leader><TAB> :b#<CR>
+nnoremap <leader>l :ls<CR>
+" file manipulation with leader
+nnoremap <leader>w :w<CR>
+nnoremap <leader>x :x<CR>
+
+" open vimrc in split
+nnoremap <leader>rc :vsplit $MYVIMRC<cr>
+" source vimrc
+nnoremap <leader>src :source $MYVIMRC<cr>
+
+" file toggle
+nnoremap <leader>z zi
" remove trailing white space on save
autocmd BufWritePre * %s/\s\+$//e
+" initialise buf for fold toggle
+autocmd BufReadPre * :normal zMzi
+
" real tab in c file for school projects
autocmd Filetype c setlocal noexpandtab