dotfiles/vim/.vimrc
2021-11-11 17:34:23 +05:30

95 lines
2.5 KiB
VimL
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

filetype plugin on
"set filetype indent on
" Syntax highlighting on
syn on
" Show title of file being edited as window title
"se title
" Make tabs appear as 4 spaces
set tabstop=4
" Make each shift to be 4 spaces
set shiftwidth=4
" Expand tabs to spaces
set expandtab
" Minimum number of lines to keep above and below cursor
"set scrolloff=0
"set textwidth=80
" Always show status line
set laststatus=2
" Don't break wrap lines mid-word
set linebreak " or just 'se lbr'
" Allow more tabs
"set tabpagemax=20
" Set color scheme
colo industry
source ~/.vim/digraphsrc.vim
if has("cscope")
source ~/.vim/cscoperc.vim
endif
" From https://stackoverflow.com/questions/2119754/switch-to-last-active-tab-in-vim
" Switch to last-active tab
if !exists('g:last_tab')
let g:last_tab = 1
let g:last_tab_backup = 1
endif
autocmd! TabLeave * let g:last_tab_backup = g:last_tab | let g:last_tab = tabpagenr()
autocmd! TabClosed * let g:last_tab = g:last_tab_backup
nmap <silent> gl :exe "tabn " . g:last_tab<cr>
" Toggle fold tree under cursor
nnoremap <Tab> zA
" " Default values for registers
" "" c with gcc
" let @c = ':w %
:!gcc % -o a.out;./a.out
'
"
" "" sml with mlton
" let @n = ':w %
:!tmux run-shell -b -t 1 "mlton -output a.out %; ./a.out"
'
"
" "" python with python3
" "let @p = ':w %
:!python3 %
'
"
" "" latex with pdflatex
" let @x = ':w %
:!pdflatex %
'
"
" "" Add code block in markdown
" let @e = 'o```Ypko'
"
" "" run sml with smlnj
" let @s = ':w %
:!rlwrap sml %
'
" https://stackoverflow.com/questions/18296192/vim-compile-and-run-shortcut
" au is short for autocmd
autocmd filetype c nnoremap <F4> :w <bar> exec '!gcc '.shellescape('%').' -o a.out && ./a.out'<CR>
autocmd filetype cpp nnoremap <F4> :w <bar> exec '!g++ '.shellescape('%').' -o a.out && ./a.out'<CR>
autocmd filetype python nnoremap <F4> :w <bar> exec '!python3 '.shellescape('%')<CR>
autocmd filetype haskell nnoremap <F4> :w <bar> exec '!ghc '.shellescape('%').' -o a.out && ./a.out'<CR>
autocmd filetype tex nnoremap <F4> :w <bar> exec '!pdflatex '.shellescape('%')<CR>
autocmd filetype dot nnoremap <F4> :w % <bar> exec '!dot -Tps '.shellescape('%').' -o '.shellescape('%:r').'.ps'<CR>"
"autocmd filetype bash nnoremap <F4> :w % <bar> exec '!bash '.shellescape('%')<CR>"
" texttt
autocmd filetype tex nnoremap <Leader>t ciw\texttt{<Esc>pa}<Esc>
" textit
autocmd filetype tex nnoremap <Leader>i ciw\textit{<Esc>pa}<Esc>
" textbf
autocmd filetype tex nnoremap <Leader>b ciw\textbf{<Esc>pa}<Esc>