2 Commits a86f8d01b1 ... aa6c09d0a5

Author SHA1 Message Date
  Daniel Sheffield aa6c09d0a5 fix simplified mapping to handle braces 3 weeks ago
  Daniel Sheffield fe04f35f62 add some comments 3 weeks ago
1 changed files with 32 additions and 5 deletions
  1. 32 5
      vim/vimfiles/vimrc

+ 32 - 5
vim/vimfiles/vimrc

@@ -65,28 +65,55 @@ set encoding=utf-8
 scriptencoding utf-8
 
 " Copy Pasta {{{
+
+" Registers
+"
 function! RegisterSwapDefaultWith()
     " Swap the default register with the contents of another
     let l = nr2char(getchar())
     execute 'let @x=@' . l . '| let @' . l . '=@" | let @"=@x'
 endfunction
 nnoremap <Leader>c :call RegisterSwapDefaultWith()<CR>
-" Swap the default register with the contents of the clipboard
 nnoremap <Leader>C :call RegisterSwapDefaultWith()<CR>+
+"
+" (visual) <LEADER>ca := swap contents of default register (") with register a
+" (visual) <LEADER>C  := swap contents of default register with clipboard (+)
+
 " }}}
 
+" Case {{{
+
+" Uppercase/Lowercase
+"
+" (visual) gu  := lowercase selection
+" (normal) guu := lowercase line
+" (visual) gU  := uppercase selection
+" (normal) gUU := uppercase line
 
 " Title Case
+"
 vnoremap gt :s/\%V\v<(.)(\w*)/\u\1\L\2/g<CR>:noh<CR>
-nnoremap gTT V:s/\v<(.)(\w*)/\u\1\L\2/g<CR>:noh<CR>
+nnoremap gtt V:s/\v<(.)(\w*)/\u\1\L\2/g<CR>:noh<CR>
+"
+" (visual) gt  := titlecase selection
+" (normal) gtt := titlecase line
+
+" }}}
 
 " Quote {{{
+
 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 ({})
+
 " }}}
 
 " Autoformatting (to be tested) {{{