如何使用 c++ 执行 gvim 命令
How to execute gvim command using c++
我需要编写一个代码来跳转到gVim中的特定给定行号。但我需要使用C++来做到这一点。有什么办法吗?
有一些方法可以通过使用C++代码执行 Linux 命令来打开 gvim。但是有没有办法使用相同的C++代码执行 gVim 命令?
你的意思是运行 linux 命令的函数system
吗?您可以将其用于任何命令和命令参数。波纹管就是例子,请根据您的要求进行修改。
int line_no = 576;
std::string file_name;
std::stringstream command;
command << "gvim +" << line_no << " " << filename;
system(command.str().c_str());
它将执行gvim +576 file_name
,在 gvim 中的特定行打开一个文件。
您可以要求vim
从命令行运行命令。请参阅 vim 命令行选项列表。
将光标定位在行上num
运行vim +num filename
,例如vim +578 filename
跳转到命名文件中的第 578 行。 vim + filename
跳到最后一行。
搜索:vim +/pattern filename
将光标定位在包含"模式"的第一行。
其他命令:vim -c command filename
执行 ex(:
( 命令。您最多可以运行 10 个命令(最多 10 个-c
选项(。
相关文章:
- 从命令行c++发送文本文件名
- 如何使用 < 和 > 命令获取 c++ 中的输入和输出?
- 为cl.exe(Visual Studio代码)指定命令行C++版本
- 如何在OMNET++中指定与命令行参数组合的输出文件名
- 使用QProcess执行命令,并将结果存储在QStringList中
- 数组长度,为什么从命令行获取时不能使用它?
- 如果用户输入无效,如何使用字符串变量-C++重复输入命令
- clang整洁10忽略了我的NOLINT命令
- 在子目录中使用target_sources()命令时用于单元测试(qtest)的项目结构
- 如何处理linux终端中带有负号(-)的C++中的命令行参数
- VS Code "command":"make"与终端窗口中的命令行"make"不同
- 使用VS Code和CMake Tools运行自定义命令
- 如何使用ESP8266向谷歌主页发送命令
- 如何使 windows 命令提示符在C++可执行文件上显示返回值?
- 未定义的引用 .. 使用 OpenCV 编译 C++ 代码时,从命令行
- 通过 Openssl 命令行加密,通过 c++ 解密
- CMake "--target install"无需"--build"命令行
- Gstreamer 管道从命令 lne 到 c 代码
- 如何使用 c++ 执行 gvim 命令
- 在_vimrc中给出的cmake和oxygen命令在gvim启动时出现错误