Last active
September 24, 2016 02:37
-
-
Save alexklapheke/58ddb2330c057817737ede3328df45fc to your computer and use it in GitHub Desktop.
Minimal .vimrc
This file contains 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
" Minimal .vimrc | |
" Author: Alex Klapheke | |
" Modified: 17 May 2016 | |
" Paths: | |
" Unix: /home/alex/.vimrc /home/alex/.vim/ | |
" OS X: /Users/Alex/.vimrc /Users/Alex/.vim/ | |
" Windows: \Users\Alex\_vimrc \Users\Alex\vimfiles\ | |
" Recommended plugins: | |
" tpope/vim-pathogen | |
" tpope/vim-unimpaired | |
" junegunn/vim-easy-align | |
" | |
" Color scheme: | |
" sjl/badwolf | |
set nocompatible | |
filetype off | |
silent! execute pathogen#infect() | |
filetype plugin indent on | |
" === Interface === {{{ | |
if has("syntax") | syntax on | endif | |
if has("mouse") | set mouse=nv | endif " disable mouse except for selections | |
if has("title") | set title | endif " show title in console title bar | |
if has("wildmenu") | set wildmenu | endif " show tab completion in status line | |
if has("statusline") | set laststatus=2 | endif " always show status line | |
set guifont=Inconsolata\ Medium\ 9 | |
set background=dark " adapt colors for background | |
silent! colorscheme badwolf | |
" set fillchars+=vert:│ " vertical box-drawing character to separate splits | |
" set list listchars=tab:│\ ,trail:␣,nbsp:∘ | |
set number " line numbers | |
if has("statusline") | |
set statusline=%f\ %r%{(&key==\"\"?\"\":\"[encr]\")}%h%y[%{&ff},%{strlen(&fenc)?&fenc:'none'}]%m%=%P\ %04l/%04c\ [x%02B] | |
endif | |
let mapleader = " " | |
" let mapleader = "\<Space>" | |
" select entire buffer | |
xnoremap <CR> <ESC>ggVG | |
onoremap <CR> :<c-u>normal! m'ggVG<cr>`' | |
" }}} | |
" === Tabs & Windows === {{{ | |
tab all " open new files in new tabs | |
" open new windows below/right of current | |
if has("windows") && has("vertsplit") | set splitbelow splitright | endif | |
nnoremap <Leader>t :tabnew<CR> | |
" Generalized split windows; Modified from: | |
" <https://technotales.wordpress.com/2010/04/29/vim-splits-a-guide-to-doing-exactly-what-you-want/> | |
nnoremap <leader>Sh :topleft vnew<CR> | |
nnoremap <leader>Sl :botright vnew<CR> | |
nnoremap <leader>Sj :topleft new<CR> | |
nnoremap <leader>Sk :botright new<CR> | |
nnoremap <leader>sh :leftabove vnew<CR> | |
nnoremap <leader>sl :rightbelow vnew<CR> | |
nnoremap <leader>sj :leftabove new<CR> | |
nnoremap <leader>sk :rightbelow new<CR> | |
" easily switch between windows... | |
nnoremap <C-j> <C-W>j | |
nnoremap <C-k> <C-W>k | |
nnoremap <C-h> <C-W>h | |
nnoremap <C-l> <C-W>l | |
" ...but keep ctrl-l (refresh window) functionality | |
nnoremap g<C-l> <C-l> | |
" open help on the right, for easier viewing | |
nnoremap <Leader>h :vertical botright help | |
" }}} | |
" === File management === {{{ | |
if has("multi_byte") | |
set encoding=utf-8 | |
set fileencoding=utf-8 | |
set fileencodings=ucs-bom,utf8,prc | |
endif | |
let g:is_bash=1 | |
" cd to dir of current file | |
nnoremap <Leader>cd :cd %:p:h<CR>:pwd<CR> | |
" keep undo files in config directory | |
if has('persistent_undo') | |
set undofile | |
if has('win32') || has('win64') | |
set undodir=$HOME/vimfiles/undo// | |
else | |
set undodir=$HOME/.vim/undo// | |
endif | |
endif | |
" put all swap files together in one place | |
if has('win32') || has('win64') | |
set directory^=$HOME/vimfiles/swap// | |
else | |
set directory^=$HOME/.vim/swap// | |
endif | |
" security features for encryption | |
if has('cryptv') | |
silent! set cryptmethod=blowfish cryptmethod=blowfish2 | |
if has('autocmd') | |
autocmd BufReadPre * if &key != "" | set viminfo= noshelltemp history=0 | endif | |
endif | |
endif | |
" easily compile tex files | |
if has('autocmd') && has('eval') && has('quickfix') | |
augroup tex | |
autocmd! | |
autocmd FileType tex compiler tex | |
" autocmd FileType tex setlocal makeprg=xelatex\ \-file\-line\-error\ \-interaction=nonstopmode\ % " Without makefile | |
autocmd FileType tex setlocal makeprg=make\ \-\-always\-make\ \-\-file=$HOME/tex.makefile\ %:p:r.pdf " With makefile | |
autocmd FileType tex setlocal errorformat=%f:%l:\ %m | |
autocmd QuickFixCmdPost [^l]* nested cwindow | |
autocmd QuickFixCmdPost l* nested lwindow | |
augroup end | |
endif | |
" }}} | |
" === Indent & Formatting === {{{ | |
if has("linebreak") | set linebreak | endif " don't break a line in the middle of a word | |
if executable("par") | set formatprg=par\ w80\ q | endif " j=justify, l=last line, f=make lines uniform | |
set tabstop=4 shiftwidth=4 softtabstop=4 | |
set shiftround " round indents to multiple of shiftwidth | |
set nrformats-=octal " don't treat numbers with leading zeroes as octal | |
set showmatch " show matching braces | |
" reselect visual block after in/dedent so we can in/dedent more | |
vnoremap < <gv | |
vnoremap > >gv | |
" }}} | |
" === Folds === {{{ | |
if has('autocmd') && has("folding") | |
set nofoldenable " open files with all folds open | |
augroup css | |
autocmd! | |
" css folding <https://stackoverflow.com/a/8677159> | |
autocmd FileType css setlocal foldmethod=marker foldmarker={,} | |
augroup end | |
endif | |
" close all folds not including current line | |
nnoremap <C-z> zMzv | |
" }}} | |
" === Searching === {{{ | |
set ignorecase | |
if has("extra_search") | set hlsearch | endif | |
" clear search highlighting with space bar | |
nnoremap <silent> g<SPACE> :noh<CR> | |
" Quickly search for non-ASCII characters: /<C-R>=NonAscii<CR><CR> | |
let NonAscii = '[^\x00-\x7F]' | |
" }}} | |
" === Diffs === {{{ | |
if has("diff") | |
set diffopt+=iwhite " ignore whiespace in diffs | |
nnoremap <silent> g<C-D> :call DiffToggle()<CR> | |
function! DiffToggle() | |
if &diff | |
windo diffoff | |
else | |
windo diffthis | |
endif | |
endfunction | |
endif | |
" }}} | |
" === Spelling === {{{ | |
" quickly correct basic spelling errors, then move to the next one | |
nnoremap z' 1z= | |
nnoremap z" 1z=]s | |
" }}} | |
" === Insert mode === {{{ | |
if has("digraphs") | |
digraphs ** 8270 " ⁎ better asterisk for linguistic examples | |
digraphs NE 8708 " ∄ | |
digraphs [[ 10214 ]] 10215 " ⟦⟧ | |
digraphs ~> 8605 <~ 8604 " ↝ ↜ | |
digraphs MN 9723 MP 9671 " ◻ (modal necessity) ◇ (modal possibility) | |
digraphs O+ 8853 " ⊕ (XOR) | |
digraphs =# 8802 " ≢ | |
digraphs T- 8868 " ⊤ (tautology) | |
digraphs \|- 8866 " ⊢ | |
digraphs \|= 8872 " ⊨ | |
digraphs \|- 8614 " ↦ | |
digraphs %% 8984 " ⌘ (cmd key on macs) | |
endif | |
" instant dummy text | |
iabbrev lorem Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. | |
" }}} | |
" vim:fdm=marker |
This file contains 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
openout_any := a | |
export openout_any | |
.PHONY: clean pdf | |
pdf : $(patsubst %.tex,%.pdf,$(wildcard *.tex)) | |
%.pdf : %.tex | |
-xelatex -file-line-error -interaction=batchmode $< | |
-bibtex $(patsubst %.tex,%,$<) | |
-xelatex -file-line-error -interaction=batchmode $< | |
xelatex -file-line-error -interaction=batchmode $< | |
# Don't remove PDFs in case of figures, etc. | |
clean : | |
rm -f *.aux *.bbl *.blg *.fdb_latexmk *.fls *.log *.out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment