Created
August 21, 2017 09:02
-
-
Save deanmalan/74e39bc998d3043645dd7d84af28ad17 to your computer and use it in GitHub Desktop.
.vimrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" When started as "evim", evim.vim will already have done these settings. | |
if v:progname =~? "evim" | |
finish | |
endif | |
" Use Vim settings, rather than Vi settings (much better!). | |
" This must be first, because it changes other options as a side effect. | |
set nocompatible | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" let Vundle manage Vundle, required | |
Plugin 'VundleVim/Vundle.vim' | |
" Vundle plugins | |
Bundle 'gabrielelana/vim-markdown' | |
Plugin 'tpope/vim-fireplace' | |
" All of your Plugins must be added before the following line | |
call vundle#end() " required | |
filetype plugin indent on " required | |
" allow backspacing over everything in insert mode | |
set backspace=indent,eol,start | |
set dir=~/.vim/swapfiles | |
set backupdir=~/.vim/backups | |
set undodir=~/.vim/undos | |
set backup " keep a backup file (restore to previous version) | |
set undofile " keep an undo file (undo changes after closing) | |
set swapfile | |
set history=50 " keep 50 lines of command line history | |
set ruler " show the cursor position all the time | |
set showcmd " display incomplete commands | |
set incsearch " do incremental searching | |
" Don't use Ex mode, use Q for formatting | |
map Q gq | |
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo, | |
" so that you can undo CTRL-U after inserting a line break. | |
inoremap <C-U> <C-G>u<C-U> | |
" In many terminal emulators the mouse works just fine, thus enable it. | |
if has('mouse') | |
set mouse=a | |
endif | |
" Switch syntax highlighting on, when the terminal has colors | |
" Also switch on highlighting the last used search pattern. | |
if &t_Co > 2 || has("gui_running") | |
syntax on | |
colorscheme smyck | |
set hlsearch | |
endif | |
" Only do this part when compiled with support for autocommands. | |
if has("autocmd") | |
" Enable file type detection. | |
" Use the default filetype settings, so that mail gets 'tw' set to 72, | |
" 'cindent' is on in C files, etc. | |
" Also load indent files, to automatically do language-dependent indenting. | |
filetype plugin indent on | |
" Put these in an autocmd group, so that we can delete them easily. | |
augroup vimrcEx | |
au! | |
" For all text files set 'textwidth' to 78 characters. | |
autocmd FileType text setlocal textwidth=78 | |
" When editing a file, always jump to the last known cursor position. | |
" Don't do it when the position is invalid or when inside an event handler | |
" (happens when dropping a file on gvim). | |
autocmd BufReadPost * | |
\ if line("'\"") >= 1 && line("'\"") <= line("$") | | |
\ exe "normal! g`\"" | | |
\ endif | |
augroup END | |
else | |
set autoindent " always set autoindenting on | |
endif " has("autocmd") | |
" Convenient command to see the difference between the current buffer and the | |
" file it was loaded from, thus the changes you made. | |
" Only define it when not defined already. | |
if !exists(":DiffOrig") | |
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis | |
\ | wincmd p | diffthis | |
endif | |
if has('langmap') && exists('+langnoremap') | |
" Prevent that the langmap option applies to characters that result from a | |
" mapping. If unset (default), this may break plugins (but it's backward | |
" compatible). | |
set langnoremap | |
endif | |
set textwidth=80 | |
set expandtab " use spaces for tabs | |
set tabstop=2 | |
set softtabstop=2 | |
set shiftwidth=2 | |
set nu | |
set showmatch " highlight matching parentheses | |
set ignorecase " ignore case when searching | |
" remove trailing spaces on save | |
autocmd BufWritePre * %s/\s\+$//e | |
"" add closing brace and tab with open brace | |
:imap { {<CR><tab><CR><BS>}<Esc>k$a | |
"" comment lines with forward slashes | |
:nmap <C-_> ^i// <Esc> | |
:nmap <C-\> ^xxx | |
:vmap <C-_> :s/^/\/\/ /g<CR> | |
:vmap <C-\> :s/^\/\/\ //g<CR> | |
autocmd Filetype gitcommit setlocal spell textwidth=72 | |
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 *.py iunmap { | |
autocmd BufNewFile,BufRead *.html iunmap { | |
autocmd BufNewFile,BufRead *.sh iunmap { | |
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() | |
"" press space to insert a single character | |
:nnoremap <Space> i_<Esc>r |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment