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

17131Re: matchit.vim et cetera

Expand Messages
  • c928400@student.dtu.dk
    Jan 3 12:06 AM
      Thus wrote Benji Fisher (benji@...) on [010101]:
      > 2. It's not a big deal, just a matter of convenience. Consider
      > MyFoo("forward") and YourFoo("backward"):

      > fun MyFoo(direction)
      > search("foo", a:direction[0])
      > endfun

      Well, you could require the direction to be specified in a format
      expected by search(). This way, you can also, easily, use "w" and "W"
      to overrule 'wrapscan'.

      > fun YourFoo(direction)
      > if a:direction == "backward"
      > let flag = "b"
      > else
      > let flag = ""
      > endif
      > search("foo", flag)
      > endfun

      If you want to do something this simple, try

      fun AnotherFoo(direction)
      call search("foo", a:direction =~? '^b\(ackward\)\=$' ? "b" : "")

      (which happens to include my favorite way of handling cases "b" or
      "backward" case insensitive.)

      "Before you criticize someone, walk
      Preben "Peppe" Guldberg __/-\__ a mile in his shoes. That way, if
      c928400@... (o o) he gets angry, he'll be a mile away
      ----------------------oOOo (_) oOOo-- - and barefoot." --Sarah Jackson
    • Show all 7 messages in this topic