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

expand variable to command line

Expand Messages
  • Aarto Matti
    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 ... What it
    Message 1 of 9 , Aug 31, 2009
      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

      --
      Aarto

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Tim Chase
      ... -tim --~--~---------~--~----~------------~-------~--~----~ You received this message from the vim_use maillist. For more information, visit
      Message 2 of 9 , Aug 31, 2009
        > 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

        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
        -~----------~----~----~----~------~----~------~--~---
      • Gary Johnson
        ... If you want to actually edit $VIM and not add more to the path ... Regards, Gary --~--~---------~--~----~------------~-------~--~----~ You received this
        Message 3 of 9 , Aug 31, 2009
          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



          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • 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 4 of 9 , Sep 1, 2009
            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 5 of 9 , Sep 1, 2009
              > 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 6 of 9 , Sep 1, 2009
                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 7 of 9 , Sep 1, 2009
                  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 8 of 9 , Sep 9, 2009
                    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 9 of 9 , Sep 14, 2009
                      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.