从VIM庆典执行当前行

编程入门 行业动态 更新时间:2024-10-25 20:21:44
本文介绍了从VIM庆典执行当前行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

此问题是类似的Vim:执行当前文件,而是执行的电流?文件我想只执行当前行。

This question is similar to Vim: execute current file? but instead of executing the current file I want to execute only the current line.

这可能吗?

更新:理想情况下,我找它可以在外壳副作用的解决方案。例如,假设我有以下行:

Update: Ideally, I am looking for solutions which can have side effects in the outer shell. For example, suppose I have the following line:

alias foo=bar

在vim运行命令,如果我开始与后壳:SH ,别名富可用,但如果我不干 VIM 使用:q ,然后别名不再

After running the command in vim, if I start a shell with :sh, the alias foo is available, but if I quit vim using :q, then the alias is no longer available.

推荐答案

没问题,你可以写当前文件的任何内容到另一个程序的标准输入:

Sure thing, you can 'write' any content of the current file into the stdin of another program:

:.w !bash

下面。(W前面的部分)是指你正在写行的范围和。是仅当前行。然后,可以使用!庆典来写那些行抨击。

Here . (the part before w) refers to the range of lines you are writing, and . is only the current line. Then you use !bash to write those lines to bash.

更多推荐

从VIM庆典执行当前行

本文发布于:2023-11-10 02:01:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1574042.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:庆典   VIM

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!