stosss
unread,Nov 17, 2012, 11:33:37 PM11/17/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Vim Users
Greetings,
This is one of my rear occasions to ask a question. I don't have any
idea what to search for to try to figure it out.
I did not create this. I have no idea how this works or what key
strokes trigger it. Can someone help me understand how to use it? It
looks like there are two or three mappings below. Does it go in the
.vimrc or somewhere else?
" Search for selected text, forwards or backwards.
vnoremap <silent> * :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy/<C-R><C-R>=substitute(
\escape(@", '/\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
vnoremap <silent> # :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy?<C-R><C-R>=substitute(
\escape(@", '?\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
" Convert curly quotes to straight.
" Any argument causes substitute to confirm changes.
function! ToStraight(line1, line2, args)
let flags = 'eg'
let range = a:line1 . ',' . a:line2
if empty(a:args)
let range = 'silent ' . range
else
let flags .= 'c'
endif
let search = @/
exe range . "s/['']/'/" . flags
exe range . 's/[""]/"/' . flags
nohl
let @/ = search
endfunction
command! -nargs=? -range ToStraight call ToStraight(<line1>, <line2>, '<args>')
Thanks for the help,
Jack