diff options
| author | Teddy Wing | 2014-11-09 12:14:44 -0500 | 
|---|---|---|
| committer | Teddy Wing | 2014-11-09 12:14:44 -0500 | 
| commit | 723053afd9e28b6e43e6461438ca305f9966f410 (patch) | |
| tree | 4602aae5cc8ab226ad9a64f172470de1abfaaa9b | |
| parent | 71bda7ca55622fcf1b938e5255a64e9f714829e8 (diff) | |
| download | auditory.vim-723053afd9e28b6e43e6461438ca305f9966f410.tar.bz2 | |
autoload/auditory.vim: Add custom `d` operator
Create a custom delete operator that plays the delete sound.
NOTES:
* Doesn't do `dd`
* I just looked at the tcomment plugin source and realised that I should
  be using plugin mappings so these can be more easily overridden. Make
  a note to look into that.
| -rw-r--r-- | autoload/auditory.vim | 27 | 
1 files changed, 27 insertions, 0 deletions
| diff --git a/autoload/auditory.vim b/autoload/auditory.vim index 8886ed2..cec02df 100644 --- a/autoload/auditory.vim +++ b/autoload/auditory.vim @@ -158,6 +158,33 @@ function! auditory#ToggleGalaxyFarFarAway()  endfunction +" Operators +" ========= +nnoremap <silent> d :set opfunc=<SID>Delete<CR>g@ +vnoremap <silent> d :<C-U>call <SID>Delete(visualmode(), 1)<CR> + +function! s:Delete(type, ...) +	let sel_save = &selection +	let &selection = "inclusive" +	let reg_save = @@ + +	call auditory#Play('/Resources/Normal_Mode/Delete.wav') + +	if a:0  " Invoked from Visual mode, use '< and '> marks. +		silent exe "normal! `<" . a:type . "`>d" +	elseif a:type == 'line' +		silent exe "normal! '[V']d" +	elseif a:type == 'block' +		silent exe "normal! `[\<C-V>`]d" +	else +		silent exe "normal! `[v`]d" +	endif + +	let &selection = sel_save +	let @@ = reg_save +endfunction + +  " Normal mode  " =========== | 
