使用 Vim 编译和运行 C++ 程序 [英] Compiling and Running a C++ Program with Vim

查看:23
本文介绍了使用 Vim 编译和运行 C++ 程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这听起来很愚蠢,但我已经在 Vim 编辑器上编写了 C++ 代码,而且我一生都无法弄清楚如何编译和运行它.我知道这非常简单,但我已经醒了太久了感谢您的帮助!

I know this sounds really dumb, but I've written a C++ code on Vim editor and for the life of me cannot figure out how to compile and run it. I know this is extremely simple but I've been awake for far too long Thanks for the help!

推荐答案

只需输入vim:

:wq

然后,在您的命令行上调用 compiler,它不是 vim 而是 g++clang++或类似的东西:

then, on your command line, invoke the compiler which isn't vim but g++ or clang++ or something like:

g++ -o myCode myCode.cpp

所有在位的选民请阅读该男子本人 Bram Moolenaar 撰写的 vim 用户手册的第 21 节,标题为:走开,然后回来".:help user-manual 会带你到那里.他基本上说在vim中编译或保存并退出,编译然后回来都很酷.根据本节的标题,我认为 Bram 更喜欢后者.他肯定已经精心制作了 vim 以最出色的方式处理后者.当我返回"到任何文件时:光标位于同一行和同一列,我可以像以前一样撤消和重做,我所有的历史记录、搜索、注册以及一切都与我离开时完全一样.和我走的时候基本看不出什么区别!

All you down voters please read section 21 of the vim user's manual by the man himself Bram Moolenaar entitled: "Go away and come back". :help user-manual will get you there. Where he basically says it's cool to either compile in vim OR save and exit, compile, and then come back. By the title of the section I presume Bram prefers the later. He most certainly has crafted vim to handle the later in a most excellent manner. When I "come back" to any file: the cursor is at the same row and column, I can undo and redo as before, and all my history, searches, registers, and everything is exactly as I left it. I basically can't see any difference from when I went away!

重新再次给所有失望的选民 - 窥视者出于许多不同的原因以多种不同的方式使用 vim.我一直在 shell 级别做很多事情,以至于持续留在 vim 中是非常愚蠢的.显然,您的选民在完全不同的情况下工作,在这些情况下,您最好留在编辑器中.请不要以为所有窥视者的工作方式都与您相同.

RE- to all you down voters again - peeps use vim in so many different ways for so many different reasons. I do so much at the shell level all the time that it would be painfully idiotic to remain continuously in vim. You down voters obviously work in completely different situations where you are good to stay inside the editor. Please stop thinking all peeps work the same way as you do.

这篇关于使用 Vim 编译和运行 C++ 程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆