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

Re: expand variable to command line

Expand Messages
  • Aarto Matti
    Thank you guys, but that doesn t expand the variable. This solution uses Netrw and works only if my variable was a path. The point is not to execute the
    Message 1 of 9 , Sep 1, 2009
    • 0 Attachment
      Thank you guys, but that doesn't expand the variable. This solution uses Netrw and works only if my variable was a path. The point is not to execute the command so I can continue typing it after the variable was expanded, do some changes to the string which was expanded etc.

      --
      Regards,
      Aarto


      On Mon, Aug 31, 2009 at 10:00 PM, Gary Johnson wrote:

      On 2009-08-31, Aarto Matti wrote:
      > Hello,
      >
      > How to print an expanded variable into vim command line? For some
      > reason I would like to map e.g. F12 to complete edit command with vim
      > user files path. I would do something like:
      >
      > :map <F12> :edit expand($VIM)
      >
      > What it prints is
      >
      > :edit expand($VIM)
      >
      > and I want
      >
      > :edit /usr/share/vim

      Just use this:

         :map <F12> :edit $VIM

      If you want to actually edit $VIM and not add more to the path
      before executing that command, use this:

         :map <F12> :edit $VIM<CR>

      Regards,
      Gary



      On Mon, Aug 31, 2009 at 9:28 PM, Tim Chase wrote:

      Several ways:

        :map <f12> :edit <c-r>=expand($VIM)<cr><cr>
        :map <f12> :exec "edit ".expand($VIM)<cr>

      -tim



      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---

    • Tim Chase
      ... then try a variant of one of my suggestions (it removes one level ... all typed literally ( and - characters as shown) -tim
      Message 2 of 9 , Sep 1, 2009
      • 0 Attachment
        > Thank you guys, but that doesn't expand the variable. This solution uses
        > Netrw and works only if my variable was a path. The point is not to execute
        > the command so I can continue typing it after the variable was expanded, do
        > some changes to the string which was expanded etc.

        then try a variant of one of my suggestions (it removes one level
        of "<cr>" from my previous post):

        :nnoremap <f12> :e <c-r>=$VIM<cr>

        all typed literally ("<" and ">" and "-" characters as shown)

        -tim



        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Aarto Matti
        Yes, that s what I needed. Thanks again! ... --~--~---------~--~----~------------~-------~--~----~ You received this message from the vim_use maillist. For
        Message 3 of 9 , Sep 1, 2009
        • 0 Attachment
          Yes, that's what I needed. Thanks again!

          On Tue, Sep 1, 2009 at 2:29 PM, Tim Chase wrote:

          > Thank you guys, but that doesn't expand the variable. This solution uses
          > Netrw and works only if my variable was a path. The point is not to execute
          > the command so I can continue typing it after the variable was expanded, do
          > some changes to the string which was expanded etc.

          then try a variant of one of my suggestions (it removes one level
          of "<cr>" from my previous post):

            :nnoremap <f12> :e <c-r>=$VIM<cr>

          all typed literally ("<" and ">" and "-" characters as shown)

          -tim



          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---

        • Aarto Matti
          Sorry, maybe I should open a new topic, but it s relevant to this one also. How to do the same but without mapping to keyboard key. For instance I call my
          Message 4 of 9 , Sep 1, 2009
          • 0 Attachment
            Sorry, maybe I should open a new topic, but it's relevant to this one also.

            How to do the same but without mapping to keyboard key. For instance I call my custom function EditVim() and it would drop me to command which already contains ":e /usr/share/vim".

            In other word I can simulate pressing ":".

            --
            Aarto
            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---

          • Tony Mechelynck
            ... Maybe you want to have a look at ... etc. Best regards, Tony. -- DeVries s Dilemma: If you hit two keys on the typewriter, the one you don t want hits the
            Message 5 of 9 , Sep 9, 2009
            • 0 Attachment
              On 01/09/09 15:54, Aarto Matti wrote:
              > Sorry, maybe I should open a new topic, but it's relevant to this one also.
              >
              > How to do the same but without mapping to keyboard key. For instance I
              > call my custom function EditVim() and it would drop me to command which
              > already contains ":e /usr/share/vim".
              >
              > In other word I can simulate pressing ":".
              >
              > --
              > Aarto

              Maybe you want to have a look at

              :help :browse
              :help 'browsedir'
              :help browsefilter
              :help :execute
              :help input()
              etc.


              Best regards,
              Tony.
              --
              DeVries's Dilemma:
              If you hit two keys on the typewriter, the one you don't want
              hits the paper.

              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_use" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • Aarto Matti
              ... Hello, browse, browsedir and browsefilter - no GUI please. execute - doesn t let me to complete the command, it just executes it as is. input - it doesn t
              Message 6 of 9 , Sep 14, 2009
              • 0 Attachment
                On Wed, Sep 9, 2009 at 10:40 PM, Tony Mechelynck wrote:

                Maybe you want to have a look at

                       :help :browse
                       :help 'browsedir'
                       :help browsefilter
                       :help :execute
                       :help input()
                etc.

                 
                Hello,

                browse, browsedir and  browsefilter - no GUI please.
                execute - doesn't let me to complete the command, it just executes it as is.
                input - it doesn't work with completion, e.g. file/dir names.

                The only thing I missing now is to know how to start command line mode from vim function.

                :nnoremap <f12> :e <c-r>=$VIM
                above does almost what I want (note no <CR> at the end), but how to do it without mapping to a key.

                --
                Regards,
                Aarto



                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_use" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---

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