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

^W macros for specifying split above/below and right/left?

Expand Messages
  • Tim Chase
    Does anybody have any hints for making an operator to attach to ^W for window manipulation that will all direction of the window? I can set
    Message 1 of 5 , Aug 29, 2003
      Does anybody have any hints for making an operator to attach to ^W for
      window
      manipulation that will all direction of the window? I can set
      (no)splitbelow/(no)splitright which will act in a global way, but I'm
      thinking
      that there should be a way (a sub-mode of ^W) that would take a direction.
      Commands like

      ^Wn
      ^W]

      and the like (which open a new window)
      Perhaps something like

      ^Wan (would create a new window "a"bove)
      ^Wun (would create a new window "u"nder the current one)
      ^Wvan or ^W,n (to create a vertical split to the left)
      ^Wvun or ^W.n (to create a vertical split to the right)

      and the same thing for thing for other splitting commands (like the
      tag-jumping
      ^W] and the "edit alternate file in another window" ^W^ ) could behave
      similarly without hand-coding each one of them? Sounds like an
      operator-pending sort of mode/mapping, but with ^W rather than your usual
      operator.

      These could be done with various mixings of the ex commands (vert, abo,
      bel,
      topleft, botright) but a straightforward mapping would require the 4
      mappings
      (one in each cardinal direction) for each splitting command which quickly
      blossoms to a whole lotta mappings :)

      -tim
    • Keith Roberts
      ... &spr = save_spr Or, instead of using l,d,u,r for left,down,up,right ... you could use the more traditional h,j,k,l [ CTRL-W CTRL-letter is always the
      Message 2 of 5 , Aug 29, 2003
        > -----Original Message-----
        > From: Tim Chase [mailto:gumnos@...]
        > Sent: Friday, August 29, 2003 10:41 AM
        > To: vim@...
        > Subject: ^W macros for specifying split above/below and right/left?
        >
        > Does anybody have any hints for making an operator to attach to ^W [...]
        >
        > Perhaps something like
        >
        > ^Wan (would create a new window "a"bove)
        > ^Wun (would create a new window "u"nder the current one)
        > ^Wvan or ^W,n (to create a vertical split to the left)
        > ^Wvun or ^W.n (to create a vertical split to the right)
        >
        I think mappings something like this should work:

        :map <c-w><c-r> :let save_spr = &splitright<cr>:set spr<cr>:sp<cr>:let
        &spr = save_spr<cr>

        Or, instead of using l,d,u,r for left,down,up,right ... you could use the
        more traditional h,j,k,l
        ['CTRL-W CTRL-letter' is always the same as 'CTRL-W letter', so you can
        safely remap them w/o losing the original functionality]

        :h CTRL-W (enter ^V^W)
      • Charles E. Campbell
        ... Here s something: map :lefta vs map :rightb vs map :bel sp map :abo sp Regards, Chip
        Message 3 of 5 , Aug 29, 2003
          On Fri, Aug 29, 2003 at 01:40:43PM -0500, Tim Chase wrote:
          > Does anybody have any hints for making an operator to attach to ^W
          > for window manipulation that will all direction of the window?
          ---------------------------------------------------------------------

          Here's something:

          map <c-w><c-h> :lefta vs<CR>
          map <c-w><c-l> :rightb vs<CR>
          map <c-w><c-j> :bel sp<CR>
          map <c-w><c-k> :abo sp<CR>

          Regards,
          Chip Campbell

          --
          Charles E Campbell, Jr, PhD _ __ __
          Goddard Space Flight Center / /_/\_\_/ /
          cec@... /_/ \/_//_/
          PGP public key: http://www.erols.com/astronaut/pgp.html
        • Tim Chase
          ... Thanks for the idea, but I ve already got something like this working. What I m hunting is a way to add a sub-mode to ^W that allows me to specify the
          Message 4 of 5 , Sep 2, 2003
            > Here's something:
            >
            > map <c-w><c-h> :lefta vs<CR>
            > map <c-w><c-l> :rightb vs<CR>
            > map <c-w><c-j> :bel sp<CR>
            > map <c-w><c-k> :abo sp<CR>

            Thanks for the idea, but I've already got something like this working.
            What I'm hunting is a way to add a sub-mode to ^W that allows me to
            specify the direction any sort of new-window, be it a split (as you
            detail--^Ws), a new window (^Wn), or a tag-jump (^W]) to a new window (or
            perhaps others that may be escaping me at the moment). So I'm looking to
            insert some character in to any of these commands to specify where to put
            the window. Perhaps a second character to specify vertical orientation.
            Something like:


            ^Was (would create a split-view window "a"bove)
            ^Wus (would create a split-view window "u"nder the current one)
            ^Wvas or ^W,s (to create a split-view vertically split window to the left)
            ^Wvus or ^W.s (to create a split-view vertically split window to the
            right)

            ^Wa] (would create a window "a"bove, jumping to the tag under the cursor)
            ^Wu] (would create a window "u"nder the current one, jumping to the tag
            under the cursor)
            ^Wva] or ^W,] (to create a vertically split window to the left, jumping to
            the tag under the cursor)
            ^Wvu] or ^W.] (to create a vertically split window to the right, jumping
            to
            the tag under the cursor)

            ^Wan (would create a new window "a"bove)
            ^Wun (would create a new window "u"nder the current one)
            ^Wvan or ^W,n (to create a new vertically split window to the left)
            ^Wvun or ^W.n (to create a new vertically split window to the right)

            Here, I'm using an optional "v" as a sub-mode to mean "make the split
            happen vertically", and then specifying an optional direction using the
            a/u (or ,/.) to override the default as declared by "splitbelow" and
            "splitright" settings. Maybe sub-mode is a misleading noun--perhaps
            "modifier" might be a better choice, somewhat like "a" and "i" for the
            text-objects?

            Sorry if I wasn't clear in my first email regarding my intent :)

            -tim
          • Tim Chase
            ... the ... I had considered that, but as they re already mapped to move between windows, and I already regularly use those commands for jumping between
            Message 5 of 5 , Sep 2, 2003
              > Or, instead of using l,d,u,r for left,down,up,right ... you could use
              the
              > more traditional h,j,k,l

              I had considered that, but as they're already mapped to move between
              windows, and I already regularly use those commands for jumping between
              windows, I was on the prowl for something that would still make sense to
              me ("a"bove, "u"nder, "," and "." are under the arrow-ish "<" and ">") and
              still not override existing commands.

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