When i try to run some commands like :make
or :!ls
, it shows the output in an altogether different screen/view and the file i am editing is not visible during this process.
Is there anyway i can still see my file and edit, while the command that i executed can probably run in a window at the bottom, probably the quick fix window?
6 Answers
If you are using vim 8 or neovim, maybe you would like to try :
http://github.com/skywind3000/asyncrun.vim ,
Nice replacement to vim-dispatch with much better user experience.
Easy to use, just start your background command by :AsyncRun (just like old "!" cmd).
Command is done in the background, no need to wait for the entire process to finish.
Output are displayed in the quickfix window, errors are matched with errorformat.
You can explore the error output immediately or keep working in vim while executing.
- Ring the bell or play a sound to notify you job finished while you're focusing on editing.
- Provide corresponding user experience in vim, neovim, gvim and macvim.
You could use vim-dispatch plugin for asynchronous build (make).
or if you simply want shell command result in a quickfix window you coud use in ex-mode:
:cexpr system('ls -alh') | copen
even better, add this to you .vimrc
command -nargs=+ Run :cexpr system('<args>') | copen
and run in ex-mode:
:Run ls -alh
That behavior is totally normal. CLI Vim doesn't come with a terminal emulator and will never do. GUI Vim comes with a dumb terminal emulator, though, and I think that's what you "remember long back".
You need a plugin for running commands in a separate Vim window. ConqueTerm is the only name I can remember at the moment but I think there are one or two others.
-
-
1
-
@romainl I do not want it to run in a separate shell. In a vim file, if i press : , it is being displayed in the last line in the monitor. Now, when i execute the command, let the command run in bash, but is there any way that the output be shown either in the last line again, or in a quickfix window?– woodstokMar 1, 2013 at 5:41
-
When you do
:make
and there are errors, those errors are always listed in the quickfix window. If you want the output of some arbitrary command to be displayed in the quickfix window you must read through:h quickfix.txt
which tells you how to format the output of your commands for use in the qf. But I suspect a serious case of XY problem, here: displaying the output of some commands in the qf window is a mean, what exactly are you trying to achieve?– romainlMar 1, 2013 at 7:38
Like romainl said, this is the normal behavior. Vim does not store the output, acting like a pager it is only shown while the external command is executed. You could capture the command output in a scratch Vim buffer (:r !ls
), use a plugin like the mentioned Conque, or split a shell window outside of Vim with the help of a terminal multiplexer like screen or tmux.
Would splitting the vim windows work for you?
- :split - splits window horizontally
- :vsplit - splits window vertically
Then you can use of the windows just for editing the file and the second one for executing via :make.
-
1No, i remember long back, in another system that the output used to come automatically in a small horizontal window at the bottom. I just dont know why its currently going to a different shell when this is executed...– woodstokFeb 28, 2013 at 12:19
-
@MIkhail: You could use Vim within a terminal multiplexer such as
tmux
to get similar functionality. Feb 28, 2013 at 13:02 -
@DanielAndersson I live and sleep in tmux :). But, :make in vim helps me in jumping to line numbers with errors, which wont be there if i run make in another window.– woodstokFeb 28, 2013 at 13:08
-
You can run
make
in the background or in another terminal and save the output to a file, then when it's done, read that file into the quickfix– garyjohnFeb 28, 2013 at 15:36 -
You may be looking for ex-mode
. If you type Q
in normal mode you will get a command prompt style buffer at the bottom of the window.
More information here: http://vimdoc.sourceforge.net/htmldoc/intro.html#Ex-mode