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

Re: Display shell output in vim split window

Expand Messages
  • Cory Echols
    After some tinkering, I came up with this version, which attempts to expand tokens mentioned in :he cmdline-special before moving the cursor to the scratch
    Message 1 of 8 , Feb 3, 2009
    • 0 Attachment
      After some tinkering, I came up with this version, which attempts to
      expand tokens mentioned in ':he cmdline-special' before moving the
      cursor to the scratch buffer:

      command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand(<q-args>)
      function! s:RunShellCommand(cmdline)
      echo a:cmdline
      let expanded_cmdline = a:cmdline
      for part in split(a:cmdline, ' ')
      if part[0] =~ '\v[%#<]'
      let expanded_part = fnameescape(expand(part))
      let expanded_cmdline = substitute(expanded_cmdline, part,
      expanded_part, '')
      endif
      endfor
      botright new
      setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap
      call setline(1, 'You entered: ' . a:cmdline)
      call setline(2, 'Expanded Form: ' .expanded_cmdline)
      call setline(3,substitute(getline(2),'.','=','g'))
      execute '$read !'. expanded_cmdline
      setlocal nomodifiable
      1
      endfunction

      It likely has problems of its own. It assumes everything that will be
      expand()'ed will result in a file name, for one thing. However, I can
      get trivial buffer name expansions to work, so I'm happy.

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