stosss wrote:
> There are curly quotes in a text file and I want to replace
> them with straight quotes. Since I don't see any way to type
> a curly quote in vim. I need to high-light one (visual-mode?
> select-mode?

I highly recommend that tip I mentioned; I use it all the time
for searching for text that I have selected.

The following is what I use (in my vimrc) to convert curly
quotes to straight:

" 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>')

If the utf-8 encoding is not corrupted, you will see the curly
quotes inside the [brackets] in the two "exe range..." lines.

Usage examples:
  :%ToStraight    " convert all
  :ToStraight     " convert current line only
  :%ToStraight c  " convert all and confirm each

John

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en

Reply via email to