2012-11-16 34 views
3

使用时! {cmd}在vim中,默认情况下,前一个命令的输出不会被清除。例如,我在VIM中执行了两个外部命令:!使! gcc。当我输入! gcc,前一个命令的输出为!使包括:在VIM中清除旧外部命令的输出


[email protected]:~$ vim 

make: *** No targets specified and no makefile found. Stop. 

shell returned 2 

Press ENTER or type command to continue 
gcc: fatal error: no input files 
compilation terminated. 

shell returned 4 

Press ENTER or type command to continue 

我希望VIM清除这些旧输出,这样我可以清楚地查看当前命令的输出,你可以提供这方面的任何建议吗?

回答

3

您可以先运行/usr/bin/clear

:!clear && make 

或者,您可以使用this tip打开一个新的暂存缓冲区。

0

通过将shell变量.vimrc设置为您可以创建的脚本的路径,您可以将vim执行的所有命令封装在任意脚本中。行添加到.vimrc

set shell=~/.vim/shell-wrapper.sh 

然后命名的脚本中,你可以运行最初请求命令之前调用clear。的~/.vim/shell-wrapper.sh最小内容:

#!/bin/bash 
clear 
shift # strip the -c that vim adds to bash from arguments to this script 
eval [email protected] 

你可以找到我的全部配置在这里:https://github.com/timabell/dotmatrix(可能会随时间而改变;最后提交在写作时是https://github.com/timabell/dotmatrix/commit/1098fcbcbcefa67b7a59d7a946cda1730db8ad8b

相关问题