|
@@ -104,13 +104,15 @@ nnoremap gtt V:s/\v<(.)(\w*)/\u\1\L\2/g<CR>:noh<CR>
|
|
|
|
|
|
function! SelectionSurroundWith()
|
|
|
" Surround selected text with a single char
|
|
|
- let l = nr2char(getchar())
|
|
|
- execute "normal! c" . l . "\<C-r>\"" . l . "\<Esc>"
|
|
|
+ let open = nr2char(getchar())
|
|
|
+ let pairs = {'(': ')', '[': ']', '{': '}', '<': '>'}
|
|
|
+ let close = get(pairs, open, open)
|
|
|
+ execute "normal! gvc" . open . "\<C-r>\"" . close . "\<Esc>"
|
|
|
endfunction
|
|
|
-vnoremap gi :call SelectionSurroundWith()<CR>
|
|
|
+vnoremap gi :<C-u>call SelectionSurroundWith()<CR>
|
|
|
"
|
|
|
" (visual) gi" := surround selection with quotes (")
|
|
|
-" (visual) gi{ := surround selection with braces (")
|
|
|
+" (visual) gi{ := surround selection with braces ({})
|
|
|
|
|
|
" }}}
|
|
|
|