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

Re: Fixing vim.vim so that square bracket jump mappings work properly in visual mode

Expand Messages
  • Stahlman Family
    ... Ah yes. That is a lower-impact solution. Thanks, Brett Stahlman ... --~--~---------~--~----~------------~-------~--~----~ You received this message from
    Message 1 of 6 , Feb 27, 2008
    • 0 Attachment
      Bram Moolenaar wrote:
      > Brett Stahlman wrote:
      >
      >> Sometimes, I wish to highlight an entire viml function visually. An
      >> obvious way to do this would be to position the cursor on the "fu!"
      >> line, hit 'V', then use the ][ mapping to jump to the endf[unction] line.
      >>
      >> This doesn't work, however, because of the way the ][ mapping is defined
      >> in the distributed version of vim.vim:
      >>
      >> noremap <silent><buffer> ][ m':call search('^\s*endf*\%[unction]\>',
      >> "W")<CR>
      >>
      >> The problem is that the execution of search() ends visual mode before
      >> search() can perform the jump. I believe this could be fixed as follows:
      >> Define separate mappings for visual mode, which wrap the call to
      >> search() within a function, which manually restores the visual selection
      >> with gv prior to calling search(). Here's a simple example, which
      >> demonstrates the concept, and appears to preserve the visual selection
      >> as expected...
      >>
      >> vnoremap <silent><buffer> ][ :<C-U>call VimBraceJump_FwdToEnd()<CR>
      >>
      >> fu! VimBraceJump_FwdToEnd()
      >> normal! gv
      >> call search('^\s*endf*\%[unction]\>', "W")
      >> endfu
      >
      > Instead of using a function it can be done this way:
      >
      > vnoremap <silent><buffer> ][ m':<C-U>exe "normal! gv"<Bar>call search('^\s*endf*\%[unction]\>', "W")<CR>

      Ah yes. That is a lower-impact solution.

      Thanks,
      Brett Stahlman

      >
      >

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    Your message has been successfully submitted and would be delivered to recipients shortly.