On 04/09/2011 12:11 PM, Spiros Bousbouras wrote:
How can you insert the output of an Ex command into the buffer
at the place where the cursor is ? Say for example in the 1st
line here I want to insert right after "you" the output of
:chdir .So I place the cursor after "you" and then do what ?

A couple options occur:

1) use :redir to a register and paste the register contents:

  :redir @a
  :chdir
  :redir END
  "ap

2) use the system() call in an expression-register to perform the command in your OS's command-interpreter:

 In insert mode in *nix:
 ^R=system('pwd')

 In insert mode in Win32:
 ^R=system('cd')

 In normal mode in *nix:
 "=system('pwd')<cr>p

 In normal mode in Win32:
 "=system('cd')<cr>p

where "^R" is control+R and "<cr>" is hitting <enter>.

For more info, you can read up at

  :help :redir
  :help i_CTRL-R
  :help @=

As a caveat, most of those end up being line-wise and have odd behaviors if your pulled-contents have a trailing newline (which is most of the time).

-tim






--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to