diff options
-rw-r--r-- | vimrc | 21 | ||||
-rw-r--r-- | zlglib.vim (renamed from functions.vim) | 23 |
2 files changed, 28 insertions, 16 deletions
@@ -8,17 +8,18 @@ set fileformats=unix,dos,mac set spelllang=en_us set switchbuf=useopen -" Outsourced functions file -runtime functions.vim - " Colors and Syntax {{{1 set t_Co=16 set background=dark -colorscheme solarized +colorscheme zlg if has('syntax') && !exists('g:syntax_on') syntax enable endif +" General purpose syntax useful in all files +highlight TrailingWhitespace ctermbg=magenta term=underline +syntax match TrailingWhitespace /\s\+$/ + " Plugin-Specific {{{1 " Use vim-plug call plug#begin('~/.vim/bundle') @@ -116,16 +117,16 @@ if has("autocmd") endif " Key Bindings {{{1 -nnoremap <leader>i :call <SID>SynStack()<CR> +nnoremap <leader>i :call zlg#SynStack()<CR> nnoremap <leader>l :set list!<CR> nnoremap <leader>n :set number!<CR> nnoremap <leader>t :setfiletype text<CR> nnoremap <leader>s :set spell!<CR> -nnoremap <leader>c :call <SID>CountCodeLines()<CR> -nnoremap <leader>d :call <SID>InsertDOW()<CR> +nnoremap <leader>c :call zlg#CountCodeLines()<CR> +nnoremap <leader>d :call zlg#InsertDOW()<CR> nnoremap <leader>D "=strftime("%Y-%m-%d %H:%M", localtime())<CR>p nnoremap <Space> za -nnoremap <silent> <F5> :call <SID>StripTrailingWhitespaces()<CR> +nnoremap <silent> <F5> :call zlg#StripTrailingWhitespaces()<CR> " Thanks to /u/spupy for these short and sweet mappings that replace the " simpler functions of tpope's surround.vim plugin. Each of these will @@ -140,12 +141,12 @@ noremap <Leader>w< <ESC>`>a><ESC>`<i<<ESC> noremap <Leader>w` <ESC>`>a`<ESC>`<i`<ESC> " super handy over SSH -noremap <Leader>q :call SwapKeys()<CR> +noremap <Leader>q :call zlg#SwapKeys()<CR> " Dvorak Hackery {{{1 if exists("g:use_dvorak") && g:use_dvorak == 1 - silent call SetKeyMap() + silent call zlg#SetKeyMap() endif " vim: foldmethod=marker diff --git a/functions.vim b/zlglib.vim index 5264701..0e280ff 100644 --- a/functions.vim +++ b/zlglib.vim @@ -1,5 +1,15 @@ +" Name: zlglib.vim +" Author: zlg <zlg+vim@zlg.space> +" License: Vim +" +" Integrate by symlinking to this file inside the 'autoload' directory: +" cd $HOME/.vim/autoload +" ln -s /path/to/zlglib.vim zlg.vim +" +" Next, hook things up as you wish via something like :call zlg#foo() + " StripTrailingWhitespaces, by Drew Neil of vimcasts.org {{{1 -function! <SID>StripTrailingWhitespaces() +function! zlg#StripTrailingWhitespaces() " Save last search and cursor position let _s=@/ let l = line(".") @@ -12,7 +22,7 @@ function! <SID>StripTrailingWhitespaces() endfunction " SynStack, by Drew Neil of vimcasts.org {{{1 -function! <SID>SynStack() +function! zlg#SynStack() if !exists("*synstack") return endif @@ -20,7 +30,7 @@ function! <SID>SynStack() endfunction " CountCodeLines, by zlg {{{1 -function! <SID>CountCodeLines() +function! zlg#CountCodeLines() let code_count = 0 for line in getbufline("%", 1, "$") if (len(line) > 0 && match(line, '\S\+') > -1) @@ -58,7 +68,7 @@ function! s:IsCommentLine(line) endfunction " InsertDOW, by zlg {{{1 -function! <SID>InsertDOW() +function! zlg#InsertDOW() " Let's backup a random register let tmpx = @x let @x = system("date +\"%a \" -d" . strftime("%Y") . "-" . substitute(expand("<cWORD>"), ":", "", "")) @@ -117,7 +127,7 @@ endfunction " SwapKeys, by zlg {{{1 " This function isn't that fancy; it just flips a variable and calls the " mapping function. -function! SwapKeys() +function! zlg#SwapKeys() if (exists("g:use_dvorak") && (g:use_dvorak == 1 || g:use_dvorak == 0)) let g:use_dvorak = (!g:use_dvorak) call SetKeyMap() @@ -139,7 +149,7 @@ endfunction " a global variable. In this case, it's g:use_dvorak, to swap between Dvorak " and QWERTY layouts. It can be extended to use any number of key mappings " that you need. -function! SetKeyMap() +function! zlg#SetKeyMap() if g:use_dvorak == 1 " I use a Dvorak keyboard, so standard vim movement keys are a hassle. " Since mnemonics are helpful all around, I need a mapping that gives me @@ -206,6 +216,7 @@ function! SetKeyMap() " Fold-related keybindings noremap zh zj noremap zt zk + echomsg "Bindings set to Dvorak" else " set qwerty keys; basically just resetting things |