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

Re: [vim] unmapping?

Expand Messages
  • Charles E. Campbell
    ... Hello! The maps in all use (:he mapleader) *except* for WS and WE (which use hardcoded backslashes). I m therefore not sure
    Message 1 of 6 , Aug 1, 2002
    • 0 Attachment
      On Thu, Aug 01, 2002 at 07:47:06AM -0400, Douglas L . Potts wrote:
      > On Wed, Jul 31, 2002 at 05:52:28PM -0400 Benji Fisher wrote:
      > > On Wednesday, July 31, 2002, at 02:44 PM, Nagle, Adrian wrote:
      > >
      > > > I recently noticed that it takes a while to move wordwise ('W').  I
      > > > just checked the mappings and I do have two mappings defined (WE and
      > > > WS).  I don't know where these mappings come from.  Until I find it, I
      > > > was going to just ':unm WE'.  But I get an error saying the mapping
      > > > doesn't exist.
      > > >
      > > > What am I doing wrong?  Can't I unmap the WE WS mappings?

      > (And Dr. Chip will probably be weighing in, about this time :))
      ---------------------------------------------------------------------

      Hello!

      The maps in <AlignMaps.vim> all use <Leader> (:he mapleader) *except*
      for \WS and \WE (which use hardcoded backslashes). I'm therefore not
      sure that Adrian's problem with WS and WE is due to mapleader; perhaps
      the backslash itself has a map??? Try :map \ to see.

      \WS and \WE ideally would be executable from inside the script only,
      but the <buffer> modifier affects the right-hand-side of a map, not its
      visibility.

      So, why not use script-local function calls? Those *can* be made
      effectively visible only with a script and would avoid polluting
      the map namespace. Here's WS() and WE() functions:

      " ---------------------------------------------------------------------

      " WS: wrapper start (internal) Produces a blank line above and
      fu! <SID>WS()
      set lz
      let b:curline=line(".")
      let b:curcol =col(".")
      put =''
      norm! mz'a
      put! =''
      let b:ch= &ch
      set ch=2
      let b:keepsearch=@/
      norm! my'zk
      endfunction

      " ---------------------------------------------------------------------

      " WE: wrapper end (internal) below, marks with 'y and 'z, also lz/unlz mode
      fu! <SID>WE()
      'y,'zs/\s\+$//e
      norm! 'yjmakdd'zdd
      exe "set ch=".b:ch
      unlet b:ch
      exe 'norm! '.b:curline.'G'.b:curcol."\<bar>"
      let @/= b:keepsearch
      set nolz
      endfunction

      " ---------------------------------------------------------------------

      and typical call pattern: :call <SID>WS()<CR>...:call <SID>WE()<CR>

      The problem is that suddenly the maps all become noisy:
      Example: \a, applied to a small test file I have:

      :s/,/;^Mint /g
      :s/,/;^Mint /g
      6 substitutions on 3 lines
      Hit ENTER or type command to continue

      I tried putting <silent> modifiers with the maps, I tried using
      "silent!":

      :silent! call <SID>WS()<CR>...:silent! call <SID>WE()<CR>
      map <silent> <Leader>a, ...etc...

      and the maps are still noisy -- it looks like nearly every ex command
      within them needs to be :silent! 'ed, whereas with the \WS and \WE
      maps (which nominally do the same thing as the functions) that wasn't
      necessary.

      Regards,
      Chip Campbell

      --
      Charles E Campbell, Jr, PhD _ __ __
      Goddard Space Flight Center / /_/\_\_/ /
      cec@... /_/ \/_//_/
      PGP public key: http://www.erols.com/astronaut/pgp.html
    • Nagle, Adrian
      ... I ... and ... it, I ... mapping ... That s what I m confused about. I don t think it has anything to do with any of my plugins (including AlignMaps.vim)
      Message 2 of 6 , Aug 1, 2002
      • 0 Attachment
        RE: [vim] unmapping?

        > On Thu, Aug 01, 2002 at 07:47:06AM -0400, Douglas L . Potts wrote:
        > > On Wed, Jul 31, 2002 at 05:52:28PM -0400 Benji Fisher wrote:
        > > > On Wednesday, July 31, 2002, at 02:44  PM, Nagle, Adrian wrote:
        > > >
        > > > > I recently noticed that it takes a while to move wordwise ('W').  I
        > > > > just checked the mappings and I do have two mappings defined (WE and
        > > > > WS).  I don't know where these mappings come from.  Until I find it, I
        > > > > was going to just ':unm WE'.  But I get an error saying the mapping
        > > > > doesn't exist.
        > > > >
        > > > > What am I doing wrong?  Can't I unmap the WE WS mappings?
        >
        > > (And Dr. Chip will probably be weighing in, about this time :))
        >  ---------------------------------------------------------------------
        >
        > Hello!
        >
        > The maps in <AlignMaps.vim> all use <Leader> (:he mapleader) *except*
        > for \WS and \WE (which use hardcoded backslashes).  I'm therefore not
        > sure that Adrian's problem with WS and WE is due to mapleader; perhaps
        > the backslash itself has a map???  Try  :map \  to see.

        That's what I'm confused about.  I don't think it has anything to do with any
        of my plugins (including AlignMaps.vim) as I've had those for a while.
        Something did however change with the backslash ('\').  I noticed (I was
        messing with menus at the time) that all of a sudden maps with a search
        pattern would "filter" out the backslash.  So a search of "/\(text\) test /\1
        other" would show up as "/(text) test/1 other".  The backslashes disappeared.
        If I escape them with another \, the search map would work.

        I feel this is the same time when I noticed something had to be mapped to 'W'
        since it would stutter when doing wordwise movements.  I figured out that 'WE'
        was a map, so I tried to delete it.  Now I'm stuck with another problem of
        trying to delete what appears to be a map of 'WE' but is defined as '\WE' in a
        plugin.

        Is there some sort of option or something that would all of a sudden require
        backslashes to be escaped?

        In AlignMaps.vim, I changed '\WE' map to '\\WE' and check with :map.  The map
        turns out to be '\WE'.  But I still can't delete it.  I don't think I can
        unmap anything that has a backslash.  I can delete other maps that do not have
        a backslash.

        I appreciate the help.

        Adrian

      Your message has been successfully submitted and would be delivered to recipients shortly.