" Disable compatibility with vi which can cause unexpected issuesset nocompatible"============================================================================="" Themes"============================================================================="" Molokai Theme ""let g:molokai_original = 1"colorscheme molokai" PaperColor Theme ""set background=darkset background=lightcolorscheme PaperColor" Enable the built-in matchit pluginruntime macros/matchit.vim" Enable type file detection. Vim will be able to try to detect the type of file in use.filetype on" Enable plugins and load plugin for the detected file type.filetype plugin on" Load an indent file for the detected file type.filetype indent on"============================================================================="" Custom Key Bindings"============================================================================="" Set comma as the <Leader>:let mapleader = ","" Remaps Esc to ,, in insert modeinoremap <Leader>, <Esc>" Use Space while in normal mode to enter commandsnnoremap <Space> :" Insert Disclaimer placed at ~/file_header.txtnnoremap <Leader>fh ggi<CR><Esc>k:r~/file_header.txt<CR> kdd" File savingnnoremap <Leader>s :w<CR>" Open netrwnnoremap <Leader>e :Ex<CR>" Go to file under cursor in vsplit modennoremap <Leader>gf <C-W>vgf" Quit vimnnoremap <Leader>q :q<CR>" Create a new tabnnoremap <Leader>n :tabnew<CR>" Turn on syntax highlightingnnoremap <Leader>son :syntax on<CR>" Turn off syntax highlightingnnoremap <Leader>sof :syntax off<CR>" Copy from cursor to line endnnoremap <Leader>y y$" Copy all the linesnnoremap <Leader>ya :%y+<CR>" Select all linesnnoremap <Leader>sa ggVG<CR>" Delete all the linesnnoremap <Leader>da :%d<CR>" Delete selection into blackhole registernnoremap <Leader>d "_d" Reload .vimrcnnoremap <Leader>v :source<Space>~/.vimrc<CR>" Ripgrep for searching through directorynnoremap <Leader>r :Rg<Space>" Display selected lines in reg/clipboardnnoremap <Leader>c :reg "" 0 1 2 3 * +<CR>" Open fzf window showing filesnnoremap <silent> <Leader>f :Files<CR>" Open fzf window for files in gitnnoremap <silent> <Leader>g :GFiles<CR>" Open fzf window to search through helpnnoremap <silent> <Leader>h :Helptags<CR>" View current key mappingsnnoremap <silent> <Leader>m :Maps<CR>" Open fzf window to search through lines in filennoremap <silent> <Leader>l :Lines<CR>" Open fzf window to search through all the commitsnnoremap <silent> <Leader>gc :Commits<CR>" Show all the highlight groupsnnoremap <Leader>hg :so<Space>$VIMRUNTIME/syntax/hitest.vim<CR>"============================================================================="" Autocompletion"============================================================================="" Automatically add closing ( { [ ' " `inoremap { {}<ESC>iinoremap ( ()<ESC>iinoremap [ []<ESC>iinoremap " ""<ESC>iinoremap ' ''<ESC>i" Custom implementation of Tab for autocompletionfunction! SmartTab() " if its the beginning of a line insert a literal tab let col = col('.') - 1 let before_cursor = getline('.')[:col('.')-2] let char = strcharpart(before_cursor, strchars(before_cursor)-1) if !col return "\<tab>" else if char =~ '\s$' return "\<Tab>" else return "\<C-N>" endif endifendfunctioninoremap <Tab> <C-R>=SmartTab()<CR>inoremap <C-Tab> <C-X><C-L>" File completion similar to bashset wildmode=longest,list,fullset wildmenu"============================================================================="" Configuration"============================================================================="" Turns syntax highlighting onsyntax on" Set the max. number of tabs that can be opened simultaneouslyset tabpagemax=50" Set required font and sizeset guifont=Bitstream\ Vera\ Sans\ Mono\ 17" Shows line numbersset number" Wrap really long linesset wrap" Highlight cursor line underneath the cursor horizontally.set cursorline" Indentation settingsset expandtabset tabstop=4set softtabstop=4set shiftwidth=4" Apply indentation to wrapped linesset breakindent" Adds 4 spaces before wrapped linesset showbreak=\ \ \ \" Display only the filename and modification status on tabs:set guitablabel=%t\ %M" Autowrap comments and allow formatting of comments using gqset formatoptions=cq" make searches case-sensitive only if they contain upper-case charactersset ignorecaseset smartcase" Show the current mode on the last line.set showmode" Perform incremental searchset incsearch" Highlight search stringset hlsearch" Set indent based folding for filesset foldmethod=indent" only fold at the highest levelset foldnestmax=1" Initially open a file unfoldedset nofoldenable" Backspace key works in all casesset backspace=indent,eol,start" Display .svh files with .sv syntax highlightingau BufRead,BufNewFile *.svh set filetype=systemverilog" Display .f files with .pl syntax highlightingau BufRead,BufNewFile *.f set filetype=tcl" Display .cfg files with YAML syntax highlightingau BufRead,BufNewFile *.cfg set filetype=yaml"autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab" Display .log files with special syntax highlightingau BufRead,BufNewFile *.log set filetype=log wrap linebreak breakat=@" Display .gzdoc files with special syntax highlightingau BufRead,BufNewFile *.gzdoc set filetype=gzdoc wrap linebreak breakat=@" Highlight the following keywordsif has("autocmd") " Highlight TODO, FIXME, NOTE, etc. if v:version > 701 autocmd Syntax * call matchadd('DiffAdd', '\W\zs\(TODO\|FIXME\|CHANGED\|HACK\)') autocmd Syntax * call matchadd('DiffChange', '\W\zs\(NOTE\|VERIFY\|REFER\)') autocmd Syntax * call matchadd('ErrorMsg', '\W\zs\(BUG\)') endifendif"============================================================================="" Status line modifications"============================================================================="" To always enable the vim status lineset laststatus=2" Building a custom status lineset statusline=" Highlight to be usedset statusline+=%#MatchParen#" Show line number with min. width for 3 digitsset statusline+=\ %3l\" Highlight to be usedset statusline+=%#StatusLineTerm#" Show the full path and filenameset statusline+=\ %f\" Highlight to be usedset statusline+=%#DiffDelete#" Show modification statusset statusline+=%m\" Show read-only statusset statusline+=%r\set statusline+=%h\set statusline+=%w\" Separation point between left and right aligned itemsset statusline+=%=" Highlight to be usedset statusline+=%#StatusLineNC#" Show detected file typeset statusline+=\ %Y\" Highlight to be usedset statusline+=%#DiffAdd#" Show file encodingset statusline+=\ %{&fileencoding?&fileencoding:&encoding}set statusline+=\[%{&fileformat}\]\" Highlight to be usedset statusline+=%#StatusLine#" Shows current_line/total lineset statusline+=\ Line:\ %3l/%3L\" Shows column numberset statusline+=\|\ Column:%3c\set statusline+=\" Get file sizes using FileSize functionset statusline+=%{FileSize(line2byte('$')+len(getline('$')))}function! FileSize(bytes) let l:bytes = a:bytes | let l:sizes = ['B', 'KB', 'MB', 'GB'] | let l:i = 0 while l:bytes >= 1024 | let l:bytes = l:bytes / 1024.0 | let l:i += 1 | endwhile return l:bytes > 0 ? printf(' %.1f%s ', l:bytes, l:sizes[l:i]) : ''endfunction"============================================================================="" netrw configuration"============================================================================="" Make the default netrw to work in tree liststyle" modes: thin, long, wide, tree"let g:netrw_liststyle = 0" To remove the netrw top banner"let g:netrw_banner = 0" To open the files in the previous window"let g:netrw_browse_split = 4" Keeps netrw open on the left side and the file on the right side"let g:netrw_altv = 1" Keep the split window size to only 30% of the window"let g:netrw_winsize = 30"============================================================================="" Plugin Configuration"=============================================================================""Ultisnips config"runtime path for ultinips pluginset runtimepath+=~/.vim/plugin/ultisnips"Set ultisnips triggers and for moving between placeholderslet g:UltiSnipsExpandTrigger="<C-B>"let g:UltiSnipsJumpForwardTrigger="<C-B>"let g:UltiSnipsJumpBackwardTrigger="<S-Tab>"let g:UltiSnipsListSnippets="<S-Tab>""folder to look for snippetslet g:UltiSnipsSnippetDirectories=['~/.vim/plugin/ultisnips/UltiSnips']"set the folder to look for snippets when UltiSnipsEdit is calledlet g:UltiSnipsSnippetStorageDirectoryForUltiSnipsEdit = ['~/.vim/plugin/ultisnips/snippets', 'snippets']
Comments