简体   繁体   English

在vim中运行缓冲区的内容

[英]Run contents of the buffer in vim

I have found a comment in a Gemfile: 我在Gemfile中找到了一条评论:

# ruby-debug19 is currently broken in the 1.9.3 release. You need to
# install it manually.
#
# To install, do this:
#     curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
#     curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
#     gem install linecache19-0.5.13.gem ruby-debug-base19-0.11.26.gem \
#       --with-ruby-include=$rvm_path/src/ruby-1.9.3-p125/
#     rm linecache19-0.5.13.gem ruby-debug-base19-0.11.26.gem
#
# When done, just:
#     bundle
#

I would now copy the file, edit the file, until it matches the given commands, chmod +x and then ! % 我现在将复制文件,编辑文件,直到它匹配给定的命令, chmod +x然后! % ! % . ! % Is there a vim way to do this? 有没有一种方法可以做到这一点?

I'm not sure if I have completely understood the question, but if you are trying to run those commands from within Vim, you can do so by selecting the lines you want to run (with V ), and then type: 我不确定我是否完全理解了这个问题,但是如果你试图从Vim中运行这些命令,你可以选择你想要运行的行(用V ),然后输入:

:w !bash

This will display as to take your selection into account: 这将显示为考虑您的选择:

:'<,'>w !bash

Hit enter and this will send your commands to be run in bash, and will display the output in a temporary buffer below. 按Enter键,这将发送您的命令以在bash中运行,并将输出显示在下面的临时缓冲区中。

You could also just select the lines the want to run and hit 您也可以选择想要运行和点击的行

!bash (no colon needed)

However that would try to write the output from bash into your current buffer, which you probably don't want in this case. 但是,这会尝试将bash的输出写入当前缓冲区,在这种情况下您可能不需要。

This is assuming you have bash installed on your system of course. 这假设你当然在你的系统上安装了bash。

See 看到

:help :w_c

in Vim for more info. 在Vim获取更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM