summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobby Bingham <koorogi@koorogi.info>2016-12-12 22:25:35 -0600
committerBobby Bingham <koorogi@koorogi.info>2016-12-12 22:36:47 -0600
commitfcd49a17daf9f507aa517567bdad16035bf81a9c (patch)
tree5f5c6830963c981c6f20749e781ab13a4cc58a6f
Add basic .vimrc
-rw-r--r--vim/.vimrc37
1 files changed, 37 insertions, 0 deletions
diff --git a/vim/.vimrc b/vim/.vimrc
new file mode 100644
index 0000000..8a10136
--- /dev/null
+++ b/vim/.vimrc
@@ -0,0 +1,37 @@
+" utf8. always utf8.
+set fileencoding=utf8
+set fileencodings=utf8
+
+" these seem reasonable
+set tabstop=4
+set softtabstop=4
+set shiftwidth=4
+
+" remove trailing whitespace when saving
+function StripTrailingWhitespace()
+ if !&binary && &filetype != 'diff'
+ normal mz
+ normal Hmy
+ %s/\s\+$//e
+ normal 'yz<CR>
+ normal `z
+ endif
+endfunction
+
+autocmd BufWritePre * :call StripTrailingWhitespace()
+
+" display absolute line numbers in insert mode, relative otherwise
+" allow ^N to toggle between them on demand
+function! NumberToggle()
+ if(&relativenumber == 1)
+ set number
+ else
+ set relativenumber
+ endif
+endfunc
+
+nnoremap <C-n> :call NumberToggle()<cr>
+
+set relativenumber
+autocmd InsertEnter * :set number
+autocmd InsertLeave * :set relativenumber