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

Re: split

Expand Messages
  • iler_ml@fastmail.fm
    ... Some weeeks ago, there was example of cmap/cabbrev that is expanded only at the beginning of the command line. I think this is very useful. Using such
    Message 1 of 5 , Jan 31, 2006
    • 0 Attachment
      "Benji Fisher" <benji@...> said:
      > A. J. Mechelynck wrote:
      > > Tony Berkopes wrote:
      > > > What is the best way to have all windows open vertical? Typing
      > > > :vs<CR> works after the file(s) are loaded. I would like any split
      > > > commands to force a vertical split.
      > >
      > > :cabbrev h vertical help
      > > :cabbrev sp vsplit
      > >...
      > I am nervous about using :cabbrev or :cmap . What happens if I
      > take this suggestion and then try
      >
      > :e myfile.sp

      Some weeeks ago, there was example of cmap/cabbrev that is expanded
      only at the beginning of the command line. I think this is very useful.
      Using such thing, you can safely redefine commands or define command
      containing characters which are normally not allowed in cmd name (e.g.
      :-x)

      I cannot find it in the archive at ther moment, or to reproduce it.
      ( It was about remapping the :/(slash at the beginning of cmd line)).
      How to make such mapping again ? Which expression checks if cursor
      is at the beginning of cmd line ?

      Yakov
      --

      iler_ml@...

      --
      http://www.fastmail.fm - Access your email from home and the web
    • Gerald Lai
      On Tue, 31 Jan 2006, iler_ml@fastmail.fm wrote: [snip] ... Here s a quick hack: fun Test() let pos = getcmdpos() let cmd = getcmdline() let vs = strpart(cmd,
      Message 2 of 5 , Feb 1, 2006
      • 0 Attachment
        On Tue, 31 Jan 2006, iler_ml@... wrote:

        [snip]
        > Some weeeks ago, there was example of cmap/cabbrev that is expanded
        > only at the beginning of the command line. I think this is very useful.
        > Using such thing, you can safely redefine commands or define command
        > containing characters which are normally not allowed in cmd name (e.g.
        > :-x)
        >
        > I cannot find it in the archive at ther moment, or to reproduce it.
        > ( It was about remapping the :/(slash at the beginning of cmd line)).
        > How to make such mapping again ? Which expression checks if cursor
        > is at the beginning of cmd line ?

        Here's a quick hack:

        fun Test()
        let pos = getcmdpos()
        let cmd = getcmdline()
        let vs = strpart(cmd, 0, pos - 1)
        let ve = strpart(cmd, pos - 1)
        let rep = pos == 1 ? "replaced" : "/"
        call setcmdpos(pos + strlen(rep))
        return vs.rep.ve
        endfun
        cnoremap / <C-\>eTest()<CR>

        Somehow, getcmdpos() doesn't work with c_ctrl-r_= in Vim 6.3. Probably
        an old bug. Otherwise, the above function will simplified to just
        (untested):

        cnoremap / <C-r>=getcmdpos() == 1 ? "replaced" : "/"<CR>

        Hope this helps.
        --
        Gerald
      Your message has been successfully submitted and would be delivered to recipients shortly.