Created
May 6, 2013 02:42
-
-
Save abatkin/5523093 to your computer and use it in GitHub Desktop.
Map \q to quote each line
Map \j to join lines with a comma
Map \s to quote and join all lines
Works in visual mode only Great for taking a list of things and quoting for use in an SQL query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vnoremap <leader>q :<c-u>call <SID>QuoteLines()<cr> | |
vnoremap <leader>j :<c-u>call <SID>JoinLines()<cr> | |
vmap <leader>s <leader>qgv<leader>j | |
function! s:JoinLines() | |
silent! execute "normal! gv:\<c-u>'<,'>-1s/\\v$/,/g\<cr>gvJ" | |
endfunction | |
function! s:QuoteLines() | |
silent! execute "normal! gv:s/\\v(^\\s*)([^[:space:]].{-})(\\s*$)/\\1'\\2'\\3/\<CR>" | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment