diff --git a/.vim/plugin/autohl.vim b/.vim/plugin/autohl.vim new file mode 100644 index 0000000..eeb9d71 --- /dev/null +++ b/.vim/plugin/autohl.vim @@ -0,0 +1,22 @@ +" Highlight all instances of word under cursor, when idle. +" Useful when studying strange source code. +" Type z/ to toggle highlighting on/off. +nnoremap z/ :if AutoHighlightToggle()set hlsendif +function! AutoHighlightToggle() + let @/ = '' + if exists('#auto_highlight') + au! auto_highlight + augroup! auto_highlight + setl updatetime=4000 + echo 'Highlight current word: off' + return 0 + else + augroup auto_highlight + au! + au CursorHold * let @/ = '\V\<'.escape(expand(''), '\').'\>' + augroup end + setl updatetime=500 + echo 'Highlight current word: ON' + return 1 + endif +endfunction diff --git a/.vim/plugin/convert.vim b/.vim/plugin/convert.vim new file mode 100644 index 0000000..d30ebf6 --- /dev/null +++ b/.vim/plugin/convert.vim @@ -0,0 +1,22 @@ + " convert rows of numbers or text (as if pasted from excel column) to a tuple +function! ToTupleFunction() range + silent execute a:firstline . "," . a:lastline . "s/^/'/" + silent execute a:firstline . "," . a:lastline . "s/$/',/" + silent execute a:firstline . "," . a:lastline . "join" + silent execute "normal I(" + silent execute "normal $xa)" + silent execute "normal ggVGYY" +endfunction +command! -range ToTuple , call ToTupleFunction() + +" convert rows of numbers or text (as if pasted from excel column) to an array +function! ToArrayFunction() range + silent execute a:firstline . "," . a:lastline . "s/^/'/" + silent execute a:firstline . "," . a:lastline . "s/$/',/" + silent execute a:firstline . "," . a:lastline . "join" + silent execute "normal I[" + silent execute "normal $xa]" +endfunction +command! -range ToArray , call ToArrayFunction() + +