Skip to content

Instantly share code, notes, and snippets.

@bantya
Last active April 23, 2017 11:59
Show Gist options
  • Save bantya/2da55bb88ce4baf1847d9c60a8d0aa3e to your computer and use it in GitHub Desktop.
Save bantya/2da55bb88ce4baf1847d9c60a8d0aa3e to your computer and use it in GitHub Desktop.
Vim: My _vimrc file
" vim: foldmethod=marker
:set nocompatible "For latest settings/options
" execute pathogen#infect()
" ####### Load external files ####### {{{1
" Load the vundle plugins file
so $HOME\plugins.vim
" Load defined support functions
so $HOME\partials\functions.vim
" ####### General Settings ####### {{{1
set autoindent "Vertical line spacing
set number "Set line number
set cindent "Set c type indentation
set laststatus=2
let mapleader = ',' "Map the , to leader command
set relativenumber " Show line numbers relative to the cursor position
set nojoinspaces " add only one space when joining sentences
set guicursor+=n:blinkon0 " stop cursor from blinking in normal mode
set matchpairs+=<:> " match angle brackets too
" ####### Spell checking ####### {{{1
nmap <F6> :set spell!<CR>
" ####### Move lines ####### {{{1
" Single line ddkP ddp unimpaired mappings
nmap <C-Up> [e
nmap <C-Down> ]e
" Multiple lines xkP`[V`] xp`[V`] unimpaired mappings
vmap <C-Up> [egv
vmap <C-Down> ]egv
" ####### Comments ####### {{{1
nmap <leader>m :call ToggleComment()<CR>
" ####### Tab navigation ####### {{{1
map <C-Tab> gt
map <C-S-Tab> gT
imap <C-Tab> <ESC>gt
imap <C-S-Tab> <ESC>gT
" map <C-1> 1gt
" map <C-0> :tablast<CR>
" Put newlines above and below current line being in normal mode
nmap g<C-o> o<ESC>k
nmap gO o<ESC>j
" ####### Functions mapping ####### {{{1
nmap <C-S-P> :call SyntCheck()<CR>
" ####### File navigation ####### {{{1
" Open the current working directory to let me edit the file from it without hassle
nmap <leader>ew :e <C-R>=expand('%:p:h').'/'<CR>
nmap <leader>es :sp <C-R>=expand('%:p:h').'/'<CR>
nmap <leader>ev :vsp <C-R>=expand('%:p:h').'/'<CR>
nmap <leader>et :te <C-R>=expand('%:p:h').'/'<CR>
" ####### Characters and Tabchars ####### {{{1
set tabstop=4
set expandtab
set shiftwidth=4
set softtabstop=4
set backspace=indent,eol,start "Make backspace behave as normal code editor
set listchars=tab:>\ ,eol:¬,space:.,extends:>,precedes:<
set sidescroll=5
set wrap
set linebreak
" note trailing space at end of next line
set showbreak=-->
" ####### Search ####### {{{1
set hlsearch "Highlight the search terms
set incsearch "Highlight the
" ####### Visual Mappings ####### {{{1
colorscheme dracula
set guifont=Fira_Code:h10
set t_Co=256 "Force the terminal to use 256 colors
set linespace=13 "Vertical spacing between lines
syntax on
set guioptions-=l "Disable right and left scrollbars in normal and split view
set guioptions-=L
set guioptions-=r
set guioptions-=R
" set cursorline
highlight NonText guifg=#4a4a59
highlight SpecialKey guifg=#4a4a59
" ####### Split navigation ####### {{{1
set splitbelow "Split should appear on right and below
set splitright
" Custom mappings for navigating in splits
nmap <C-h> <C-w><C-h>
nmap <C-l> <C-w><C-l>
nmap <C-k> <C-w><C-k>
nmap <C-j> <C-w><C-j>
" ####### Mappings ####### {{{1
" Add shortcut for vimrc file
nmap <Leader>tv :tabedit $MYVIMRC<CR>
" Disable search highlighting
nmap <Leader><space> :nohlsearch<CR>
" Save, close, new, open:file; next, previous:tab
nmap sv :w<CR>
nmap cl :bd<CR>
nmap nw :enew<CR>
nmap of :browse confirm e<CR>
nmap tc :tabc<CR>
" Toggle invisible chars
nmap <Leader>l :set list!<CR>
" Code folding mapping
nmap <Space> za
vmap <Space> za
nmap <Space>m zM
vmap <space>m zM
" Vimgrep search commands
nmap [q :cprev
nmap ]q :cnext
nmap [Q :cnext
nmap ]Q :clast
" ####### Auto-Commands ####### {{{1
" Automatically source vimrc file on save
augroup autosourcing
autocmd!
" autocmd BufWritePre *.c,*.cpp,*.java,*.php :call <SID>StripTrailingWhitespaces()
autocmd BufWritePre *.php,*.html,*css,*.js %s/\s\+$//e
autocmd BufWritePost $MYVIMRC nested source $MYVIMRC
augroup END
" ####### Plugin Mappings ####### {{{1
set runtimepath^=$VIM\vimfiles\bundle\ctrlp.vim
nmap <C-b> :NERDTreeToggle<CR>
" ####### Autocenter ####### {{{1
nmap G Gzz
nmap n nzz
nmap N Nzz
nmap } }zz
nmap { {zz
" ####### Filetype stuff ####### {{{1
filetype plugin indent on
" ####### Powerline Statusbar ####### {{{1
set ambiwidth=double
set encoding=utf-8
scriptencoding utf-8
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'component': {
\ 'readonly': '%{&readonly?"x":""}',
\ },
\ 'separator': { 'left': '', 'right': '' },
\ 'subseparator': { 'left': '|', 'right': '|' }
\ }
" ####### Plugins mappings ####### {{{1
" Tabular
if exists(':Tab')
nmap <leader>a= :Tab /=<CR>
vmap <leader>a= :Tab /=<CR>
nmap <leader>a: :Tab /:\zs<CR>
vmap <leader>a: :Tab /:\zs<CR>
endif
"Gundo.vim
nnoremap <F5> :GundoToggle<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment