1

I think my question is related to this question, but I not sure how to make it work for what I want to do.

In my vimrc I have a this function:

func! AutoGo()
   exec "w" 
   exec "!auto-go"
endfunc

I want to open a new split window in vim of the output of my exec "!auto-go" command. Something like this:

func! AutoGo()
   exec "w" 
   output = exec "!auto-go"
   vsplit output

endfunc

I also found this resource, but I can't get it to work. How can I achieve this?

Community
  • 1
  • 1
Amozoss
  • 1,445
  • 1
  • 11
  • 12

1 Answers1

1

If you want to execute external command and capture the output in your script, you could use system() function. After you got the command output, to display the output in split, you could vnew +{cmd}

Kent
  • 189,393
  • 32
  • 233
  • 301
  • This is close to what I want, but for some reason, it's opening my file, instead of the output of my script. This is what I tried "new +{system("!auto-go")}" Do you know why its my file rather than my script output? – Amozoss Nov 29 '13 at 22:06
  • try removing the `!` in `system()` @Amozoss – Kent Nov 30 '13 at 00:32
  • Thanks for your help. I have the issue of "E492: Not an editor command: system("auto-go")." I guess I had the same issue with "system("!auto-go"), I just had forgotten to reload my vimrc. It seems like it should work because exec "!auto-go" works just fine. – Amozoss Nov 30 '13 at 03:56