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

Wishlist

Expand Messages
  • Mikolaj Machowski
    Hi, Because Bram has holidays I can post some thoughts without cold shower ;) And maybe there are ways to workarond it? 1. change value return by substitute().
    Message 1 of 4 , Nov 27, 2002
      Hi,

      Because Bram has holidays I can post some thoughts without
      cold shower ;)
      And maybe there are ways to workarond it?

      1.
      change value return by substitute().
      Now:
      let value = "asdf"
      let value2 = substitute(value, 'a', 'e', '')
      echo value2
      esdf
      echo value
      asdf

      Dream:
      let value = "asdf"
      let value2 = substitute(value, 'a', 'e', '')
      echo value2
      1
      echo value
      esdf

      Gain:
      It is possible to make something like:
      if substitute(value, 'a', 'e', '')
      do smth
      else
      do smth else
      endif

      1a.
      Also it would be nice if substitute() works directly on lines


      2.
      String multiplier (as 'x' in Perl).
      I know it can be done with 'while' but this is very awkward.
      let i = 1
      let multi_value = 10
      let string = 'asdf'
      while i <= 10
      let multi_string = ''
      let multi_string = multi_string . 'asdf'
      let i = i + 1
      endwhile

      It would be much nicer to do:
      let multi_value = 10
      let string = 'asdf'
      let multi_string = 10 x string


      That's all for now :)

      Mikolaj
      --
      LaTeX + Vim = http://vim-latex.sourceforge.net/
      Learn Touch Typing with Vim:
      http://vim.sourceforge.net/script.php?script_id=461
    • Charles E. Campbell
      ... Never happen -- code has been written that would be severely impacted by such a change. The style you prefer presumes call-by-reference, whereas AFAICT
      Message 2 of 4 , Nov 27, 2002
        On Wed, Nov 27, 2002 at 12:47:37PM +0100, Mikolaj Machowski wrote:
        > And maybe there are ways to workaround it?
        >
        > 1. change value return by substitute().
        > Now:
        > let value = "asdf"
        > let value2 = substitute(value, 'a', 'e', '')
        > echo value2
        > esdf
        > echo value
        > asdf
        >
        > Dream:
        > let value = "asdf"
        > let value2 = substitute(value, 'a', 'e', '')
        > echo value2
        > 1
        > echo value
        > esdf

        Never happen -- code has been written that would be severely impacted by
        such a change. The style you prefer presumes call-by-reference,
        whereas AFAICT vimL is all call-by-value.

        You could use match() to test if the pattern is present or not
        in the input string (it would return -1 on not-present, 0+
        otherwise).

        > Gain:
        > It is possible to make something like:
        > if substitute(value, 'a', 'e', '')
        > do smth
        > else
        > do smth else
        > endif

        if match(value,'a') != -1
        do something
        else
        do something_else
        endif

        > 2.
        > String multiplier (as 'x' in Perl).
        > I know it can be done with 'while' but this is very awkward.
        > let i = 1
        > let multi_value = 10
        > let string = 'asdf'
        > while i <= 10
        > let multi_string = ''
        > let multi_string = multi_string . 'asdf'
        > let i = i + 1
        > endwhile
        >
        > It would be much nicer to do:
        > let multi_value = 10
        > let string = 'asdf'
        > let multi_string = 10 x string

        string to be repeated
        vvvv
        :exe "norm! o\<Esc>10iasdf\<Esc>0D:let multi_string=@".'"'."\<CR>dd"
        ^^
        qty of repeats

        Regards,
        C Campbell

        --
        Charles E Campbell, Jr, PhD _ __ __
        Goddard Space Flight Center / /_/\_\_/ /
        cec@... /_/ \/_//_/
        PGP public key: http://www.erols.com/astronaut/pgp.html
      • Mikolaj Machowski
        ... Thanks for information. ... Thanks :) I added k to end in start line. Mikolaj
        Message 3 of 4 , Nov 28, 2002
          On Wed, Nov 27, 2002 at 04:38:46PM -0500, Charles E. Campbell wrote:
          > Never happen -- code has been written that would be severely impacted by
          > such a change. The style you prefer presumes call-by-reference,
          > whereas AFAICT vimL is all call-by-value.

          Thanks for information.

          > string to be repeated
          > vvvv
          > :exe "norm! o\<Esc>10iasdf\<Esc>0D:let multi_string=@".'"'."\<CR>ddk"
          > ^^ ^
          > qty of repeats

          Thanks :)
          I added k to end in start line.

          Mikolaj
        • Mikolaj Machowski
          ... Another idea: I have 2 files: 1.vim ... source 2.vim let var2 = var. 2 ... 2.vim ... let var = asdf ... :source treats 2.vim as external file thus all
          Message 4 of 4 , Nov 28, 2002
            On Wed, Nov 27, 2002 at 12:47:37PM +0100, Mikolaj Machowski wrote:
            > Hi,
            > Because Bram has holidays I can post some thoughts without
            > cold shower ;)
            > And maybe there are ways to workarond it?

            Another idea:
            I have 2 files:
            1.vim
            --------

            source 2.vim
            let var2 = var."2"

            -------

            2.vim
            -------

            let var = "asdf"

            ------

            ":source" treats 2.vim as external file thus all variables, functions
            etc. have another "nationality" and have globalization flag "g:".
            Wouldn't be nice to have command ":readin"?
            ":readin" would source file but all variables and functions from
            "daughter file" would be treated as local to "mother file".

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