" set currently marked area into parentheses: Use visual mode to
" select text, then press ,[ for example to insert [] around selected
" text
vnoremap ,( <ESC>`>a)<ESC>`<i(<ESC>`>ll vnoremap ,< <ESC>`>a><ESC>`<i<<ESC>`>ll vnoremap ,[ <ESC>`>a]<ESC>`<i[<ESC>`>ll vnoremap ,{ <ESC>`>a}<ESC>`<i{<ESC>`>ll vnoremap ,$ <ESC>`>a$<ESC>`<i$<ESC>`>ll vnoremap ," <ESC>`>a"<ESC>`<i"<ESC>`>ll
"set Control-S to 'Save File'
imap <C-S> <C-O>:w<CR> nmap <C-S> :w<CR>
" Replace selected text in complete document
" select text in visual mode, press ,s and you'll get a prompt asking
" for the new text.
vmap ,s y:%s/<C-R>"//g<Left><Left>
" htmlify; I wrote this when writing this webpage. It replaces all
" < and > in the selected area with the html-code < and >
" Use in visual mode
vnoremap ,h :s/>/\>/g<CR>:nohl<CR>:'<,'>s/</\</g<CR>:nohl<CR>
" While typing a word, change case first letter of this word by typing ~w
" You can just continue typing...
imap ~w <ESC>mzB~`za
" Move cursor out of current parenthese region:
" if you have: (text <CURSOR> text)x
" and press Control-J, the cursor moves to the position marked with x
imap <C-J> <ESC>%%a
" Mappings for changing part of words with CamelCase:
" cu changes to next uppercase letter, du deletes
fun! DelToUpcaseLetter() let line=getline(".") let col=col(".") " Search for not-lowercase letters to stop at word end let nextUp = match(line, "\\L", col) if nextUp != -1 call setline(line("."), strpart(line, 0, col-1) . strpart(line, nextUp)) endif endfun nmap cu :call DelToUpcaseLetter()i nmap du :call DelToUpcaseLetter()