Tuesday, September 1, 2009

Re: expand variable to command line

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
-~----------~----~----~----~------~----~------~--~---

No comments:

Post a Comment