Skip to content

Instantly share code, notes, and snippets.

@delenamalan
Last active August 14, 2016 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save delenamalan/a663b2d0870c966e9de9 to your computer and use it in GitHub Desktop.
Save delenamalan/a663b2d0870c966e9de9 to your computer and use it in GitHub Desktop.
My .vimrc. There's still a lot I want to add and fix.
colorscheme peachpuff
set textwidth=80
set tabstop=2
set expandtab " use spaces for tabs
set softtabstop=2
set shiftwidth=2
set autoindent
syntax on
set showmatch " highlight matching parentheses
set ignorecase " ignore case when searching
"set hlsearch " highlight all matches
"set foldmethod=syntax
"set foldenable " don't fold files by default on open
set backup
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set backupskip=/tmp/*,/private/tmp/*
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set writebackup
" press space to insert a single character
:nmap <Space> i_<Esc>r
:nmap <F2> :w<enter>
:imap { {<CR><tab><CR><BS>}<Esc>k$a
:nmap <C-_> ^i// <Esc>
:nmap <C-\> ^xxx
:vmap <C-_> :s/^/\/\/ /g<CR>
:vmap <C-\> :s/^\/\/\ //g<CR>
"Always show current position
set ruler
autocmd Filetype gitcommit setlocal spell textwidth=72
autocmd BufNewFile,BufRead *.tex set spell
autocmd BufNewFile,BufRead *.tex iunmap {
autocmd BufNewFile,BufRead *.tex nmap <F5> :!pdflatex %<enter>
autocmd BufNewFile,BufRead *.tex :nmap <C-_> ^i% <Esc>
autocmd BufNewFile,BufRead *.tex :nmap <C-\> ^xx
autocmd BufNewFile,BufRead *.tex :vmap <C-_> :s/^/% /g<CR>
autocmd BufNewFile,BufRead *.tex :vmap <C-\> :s/^% //g<CR>
autocmd BufNewFile,BufRead *.py :nmap <C-_> ^i# <Esc>
autocmd BufNewFile,BufRead *.py :nmap <C-\> ^xx
autocmd BufNewFile,BufRead *.py :vmap <C-_> :s/^/# /g<CR>
autocmd BufNewFile,BufRead *.py :vmap <C-\> :s/^# //g<CR>
autocmd BufNewFile,BufRead *.py nmap <F5> :!python %<enter>
autocmd BufNewFile,BufRead *.sh :nmap <C-_> ^i# <Esc>
autocmd BufNewFile,BufRead *.sh :nmap <C-\> ^xx
autocmd BufNewFile,BufRead *.sh :vmap <C-_> :s/^/# /g<CR>
autocmd BufNewFile,BufRead *.sh :vmap <C-\> :s/^# //g<CR>
autocmd BufNewFile,BufRead *.rb iunmap {
autocmd BufNewFile,BufRead *.rb :nmap <C-_> ^i# <Esc>
autocmd BufNewFile,BufRead *.rb :nmap <C-\> ^xx
autocmd BufNewFile,BufRead *.rb :vmap <C-_> :s/^/# /g<CR>
autocmd BufNewFile,BufRead *.rb :vmap <C-\> :s/^# //g<CR>
autocmd BufNewFile,BufRead *.hs :nmap <C-_> ^i-- <Esc>
autocmd BufNewFile,BufRead *.hs :nmap <C-\> ^xxx
autocmd bufnewfile,bufread *.hs :vmap <c-_> :s/^/{- /g<cr>gv:s/$/ -}/g<cr>
autocmd BufNewFile,BufRead *.hs :vmap <C-\> :s/^{- //g<CR>gv:s/ -}$//g<CR>
autocmd BufNewFile,BufRead *.html* iunmap {
autocmd BufNewFile,BufRead *.html* :nmap <C-\> ^xxxxx$xxxx
autocmd bufnewfile,bufread *.html* :vmap <c-_> :s/^/<!-- /g<cr>gv:s/$/ -->/g<cr>
autocmd BufNewFile,BufRead *.html* :nmap <C-_> ^i<!-- <Esc>$a --><Esc>
autocmd BufNewFile,BufRead *.html* :vmap <C-\> :s/^<!-- //g<CR>gv:s/ -->$//g<CR>
autocmd BufNewFile,BufRead *.txt iunmap {
autocmd BufNewFile,BufRead *.md iunmap {
autocmd BufNewFile,BufRead *.hs iunmap {
" Paste without overwriting register
function! RestoreRegister()
let @" = s:restore_reg
return ''
endfunction
function! s:Repl()
let s:restore_reg = @"
return "p@=RestoreRegister()\<cr>"
endfunction
" NB: this supports "rp that replaces the selection by the contents of @r
vnoremap <silent> <expr> p <sid>Repl()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment