aboutsummaryrefslogblamecommitdiffstats
path: root/vim/vimrc
blob: 2c8807c5edb11aedb99e39dff785551f44ddaba7 (plain) (tree)
1
2
3
4
5
6
7
8
                

                                                                                            




                                                          






                                 




                                                  
 








                                                                     














                                                                             

                 
               
                
                                          































                                                                                                                       


                                                







                                                          









                                                                                                                        

                      
                                                                
                                    
                                                          





                                                           












                                                                                                          
                   
                   
 







                                                                
















                                                                         
           
set nocompatible
syntax on			"turn syntax highlighting on
filetype plugin indent on	"load plugin and indent files associated a detected filetype

" macro to go to end of sentence and add a line break (for
" one-line-per-sentence vimming...)
let @s = ")i\<BS>\<CR>\<Esc>"

" leader
let maplocalleader = "\\"
let mapleader = ","

" encryption method when using :X
set cm=blowfish2

" Underline the current line, based on its length.
noremap <silent> <leader>ul mmyypVr-<Esc>`m
"
" Show the 'list' characters.
noremap <silent> <leader>ls :set list!<CR>

" Remove double- or single-quotes, or graves wrapped around a string.
noremap <silent> <leader>rdq mmF"xf"x`m
noremap <silent> <leader>rsq mmF'xf'x`m
noremap <silent> <leader>rg mmF`xf`x`m
 
" Jump up or down by 10 lines.
noremap <silent> J 10j
noremap <silent> K 10k

" Place timestamps, be it date (YYYY-MM-DD) or time (HH:MM:SS).
if (exists("*strftime"))
	noremap <silent> <leader>date "=strftime("%F")<CR>p9h
	noremap <silent> <leader>time "=strftime("%X")<CR>p7h
endif
"
" Execute the current line with BASH.
noremap <silent> <leader>rl :.w !bash<CR>

" Run the current file with PERL, Python, BASH, or a Bourne Shell derivative.
noremap <silent> <leader>rpl :!clear; perl %<CR>
noremap <silent> <leader>rpy :!clear; python %<CR>
noremap <silent> <leader>rb :!clear; bash %<CR>
noremap <silent> <leader>rs :!clear; sh %<CR>

set shell=/bin/sh
set hi=500
set scrolloff=0
set novisualbell
set relativenumber	"show line numbers
set wildmenu	"enable a menu that shows tab completion options in the status bar
set wildchar=<TAB>
set showmatch	"highlights matching brackets on cursor hover
set ruler	"show cursor position in status bar
set showcmd	"shows the normal mode command before it gets executed
set encoding=utf-8
set fileformats=unix,dos,mac
set nohlsearch	"highlights searches
set incsearch	"incremental search (searches character by character)
set ignorecase	"ignores the case of a search
set smartcase	"only ignores case if there are no capital letters in search (only works after ignorecase has been set)
set tabstop=4		"the amount of spaces that vim will equate to a tab character
set softtabstop=4	"like tabstop, but for editing operations (insert mode)
set splitbelow " split horiz below
set noswapfile
set splitright " split new to the right when doing vertical
set shiftwidth=4	"used for autoindent and << and >> operators in normal mode
set autoindent		"copies indent from current line to the next line
set expandtab		"tabs will expand to whitespace characters
set esckeys		"allows function keys to be recognized in Insert mode
set ttimeoutlen=20	"timeout for a key code mapping
set timeoutlen=1000	"time(ms) to wait for key mappings
set hidden
set t_Co=256
"set t_Co=0 - switches off all colours
set path+=**
set more
set colorcolumn=0
set equalalways
set showmode
set nobackup
set listchars=tab:»→,trail:␣
if executable('rg')
	set grepprg=rg\ --color=never\ --vimgrep
endif

" i don't bother with folding, but it's here if i need it.
if has('folding')
	set foldmethod=marker
	set foldmarker=#\ {{{,#\ }}}
	set viewoptions=folds,options,cursor,unix,slash
endif

" clear search highlights
nnoremap <leader><space> :noh<cr>:call clearmatches()<cr>

" previews in netrw
let g:netrw_preview = 1

" journal stuff
autocmd BufNewFile,BufReadPost *.md map <leader>jj <Esc>:r! date +" - \%H:\%M: "<ENTER>kJA<Esc>$<space><Esc> 
autocmd BufNewFile,BufReadPost *.md map <leader>jd <Esc>:r! date +"(\%Y-\%m-\%dT\%H:\%M)"<ENTER>i<backspace><space><Esc>

" ghetto note system
" Go to index of notes
nnoremap <leader>ni :e $NOTES_DIR/index.md<CR>:cd $NOTES_DIR<CR>
" Depends on grepprg being set to rg
command! -nargs=1 Ngrep grep "<args>" -g "*.md" $NOTES_DIR
nnoremap <leader>nn :Ngrep 

" open quicklist vertical
command! Vlist botright vertical copen | vertical resize 50
nnoremap <leader>v :Vlist<CR>

" Search with ripgrep
command! -bang -nargs=* Rg
      \ call fzf#vim#grep(
      \   'rg --column --line-number --no-heading --color=always --ignore-case '.shellescape(<q-args>), 1,
      \   <bang>0 ? fzf#vim#with_preview('up:60%')
      \           : fzf#vim#with_preview('right:50%:hidden', '?'),
      \   <bang>0)

nnoremap <C-p>a :Rg 

"" Quick Editing vimrc
nnoremap <leader>ev <C-w>s<C-w>j<C-w>L:e $MYVIMRC<cr>

set background=dark
colorscheme hipster

" manual highlights
" highlight Visual ctermfg=black ctermbg=LightMagenta
" highlight SignColumn ctermbg=black ctermfg=white
" highlight Comment ctermfg=DarkGray
" highlight DiffAdd term=bold ctermfg=yellow ctermbg=black
" highlight DiffDelete term=bold ctermfg=red ctermbg=black
" highlight DiffChange term=bold ctermfg=black ctermbg=DarkGreen

augroup general
    autocmd!
    "keep equal proportions when windows resized
    autocmd VimResized * wincmd =
    "save cursor position in a file
    autocmd BufReadPost * if line("'\"") > 1 && line("'\"")
                \ <= line("$") | exe "normal! g'\"" | endif
augroup END

augroup languages
    autocmd!
    autocmd BufNewFile,BufRead *.bash set syntax=sh
    autocmd FileType python xnoremap <leader>r <esc>:'<,'>:w !python3<CR>
    autocmd FileType go set noexpandtab
    autocmd FileType html :syntax sync fromstart
    autocmd FileType html,javascript,css,json,yaml,sh
                \ setlocal ts=2 sts=2 sw=2 expandtab
augroup END