Loading ...
Sorry, an error occurred while loading the content.
 

Mappings, no idea how to use.

Expand Messages
  • stosss
    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
    Message 1 of 2 , Nov 17, 2012
      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

      --
      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
    • John Beckett
      ... The first extract you posted comes from: http://vim.wikia.com/wiki/Search_for_visually_selected_text which was mentioned along with your second extract
      Message 2 of 2 , Nov 17, 2012
        stosss wrote:
        > 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?

        The first extract you posted comes from:
        http://vim.wikia.com/wiki/Search_for_visually_selected_text

        which was mentioned along with your second extract here:
        http://groups.google.com/group/vim_use/browse_thread/thread/6f7b894aa05c5bb7

        In the latter, I mentioned that the code is from my vimrc, and
        included some usage examples.

        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
      Your message has been successfully submitted and would be delivered to recipients shortly.