The question is to all you people, who use Vim to develop C++ applications.
问题是所有使用Vim开发c++应用程序的人。
There was a period in my life, which can be described as 'I hate Vim!!!'..'Vim is nice!'
在我的生命中有一段时间,可以说是“我讨厌Vim!!!”“Vim很好!”
However, having grown up mostly on Microsoft development IDEs, I've got used to those F5-F11 shortcuts when debugging code, watch window, call stack and the main code - all visible without need to type any GDB commands.
但是,我主要是在Microsoft开发ide中长大的,我已经习惯了在调试代码、监视窗口、调用堆栈和主代码时使用F5-F11快捷键——这些都是可见的,不需要输入任何GDB命令。
So, here is the question:
问题是:
Do you use Vim as well for debugging? Or do you switch to some IDE for this purpose? Which one?
您是否也使用Vim进行调试?还是为了这个目的而切换到IDE ?哪一个?
For those who use Vim to debug code: are there plugins to set breakpoints in editor, highlight the line we're currently debugging, auto-navigation during step, step into, step out?
对于那些使用Vim调试代码的人:是否有插件在编辑器中设置断点,突出显示我们当前正在调试的行,在步骤、步骤、步骤中自动导航?
Please, don't tell me you use GDB as command line, see only one line which is debugged, etc.
请不要告诉我您使用GDB作为命令行,只看到正在调试的一行,等等。
5 个解决方案
#1
65
In contrast with the other answers, there are at least three options that do just what you require: clewn, pyclewn and vimgdb.
与其他答案相比,至少有三个选项可以满足您的要求:clewn、pyclewn和vimgdb。
All three projects are related. vimgdb is a patch against Vim and requires Vim to be recompiled. clewn is a standalone program that communicates with Vim through the Netbeans socket interface. This requires Vim to be built with the +netbeans
option (this is the case in recent Linux distributions so it shouldn't be a problem).
这三个项目都是相关的。vimgdb是一个针对Vim的补丁,需要重新编译Vim。clewn是一个独立的程序,通过Netbeans套接字接口与Vim通信。这需要使用+netbeans选项来构建Vim(在最近的Linux发行版中就是这种情况,所以应该不会出现问题)。
To quote from the clewn's website:
引用clewn的网站:
Clewn implements full gdb support in the vim editor: breakpoints, watch variables, gdb command completion, assembly windows, etc.
在vim编辑器中,Clewn实现了完整的gdb支持:断点、监视变量、gdb命令完成、装配窗口等。
I think you should definitely give it a go.
我想你一定要试一试。
The homepage of the pyclewn website shows a comparison between the three projects.
pyclewn网站的主页显示了这三个项目的对比。
A few months ago I tried pyclewn. It was a bit difficult to set up, but it looks well though out and promising. I just did some tests and you could set bookmarks, etc., the usual stuff you would expect from a graphical debugger. I ended up not using it for contingent reasons but I am keen to give it another try.
几个月前我试着用pyclewn。这是有点困难的设立,但它看起来很好尽管外面和有希望。我只是做了一些测试,你可以设置书签,等等,你可以从图形调试器中得到的通常的东西。我最终没有因为偶然的原因使用它,但我很想再尝试一次。
#2
12
Vim is a nice editor, but to do debugging I use a debugger (like GDB).
Vim是一个很好的编辑器,但是为了进行调试,我使用了调试器(如GDB)。
But you don't have to use GDB in text mode; you can use a graphical frontend like KDbg, DDD or Insight.
但你不必在文本模式中使用GDB;您可以使用图形化的前端,如KDbg、DDD或Insight。
There are ways of getting GDB into Vim (but then you do get text based debugging).
有一些方法可以将GDB放到Vim中(但是您可以获得基于文本的调试)。
#3
3
Using a source level debugger is only one of many ways to diagnose faulty program behavior, and I rarely find myself launching one -- despite the fact that it is very easy to do.
使用源代码级调试器只是诊断程序错误行为的众多方法之一,我很少发现自己启动了一个——尽管这很容易做到。
So for me, there is simply no inherent advantage to using a text editor that happens to also be a debugger. Instead, I use the text editor that I prefer -- independent of what debugger I choose to use. At the moment, I mostly use gedit and kdbg for these purposes, but these choices evolve independently over time.
因此,对于我来说,使用一个碰巧也是调试器的文本编辑器并没有固有的优势。相反,我使用我喜欢的文本编辑器——独立于我选择使用的调试器。目前,我主要使用gedit和kdbg来实现这些目的,但是这些选择随着时间的推移而独立地发展。
#4
1
Having just recently worked on an application for a long time that required a bunch of stuff to be in place on the box it was running (appliance set up), I wrote code in vim, had scripts which automated building, pushing it to a server, which had a script there to notice the sentinel file pushed along with the binaries. This would then restart the appropriate services on the box, and in another ssh window I had a tail -f
running on my log file.
最近刚刚在申请工作很长时间,需要很多东西在盒子里运行(设备设置),在vim中我写的代码,脚本自动化建筑,推到一个服务器,它有一个脚本需要注意哨兵文件和二进制文件。然后,这将重新启动框上的适当服务,在另一个ssh窗口中,我的日志文件上运行一个tail -f。
Long story short, I didn't use a debugger at all. If I had something die unexpectedly, I'd just bump up logging levels, redo it, and see what was the last thing logged before it died, then analyze that and fix the issue.
长话短说,我根本不用调试器。如果我意外地死掉了,我就会提高日志级别,重做它,看看在它死前最后记录的是什么,然后分析并修复这个问题。
The nice thing was that when something had problems in a customer environment, I'd just ask for a Debug-level log and could identify the issue without even requiring access to their server.
好在当客户环境中出现问题时,我只需要一个调试级别的日志,就可以识别问题,甚至不需要访问他们的服务器。
... but yes, there were times when it would have been nice to have a debugger.
…但是,是的,有时使用调试器会更好。
#5
0
GDB edit
command
GDB编辑命令
Opens an editor on the current line using the command:
使用以下命令在当前行上打开一个编辑器:
$EDITOR +<current-line> <current-file>
The default editor
is ex
, but vim
also understands the +<current-line>
format.
默认编辑器是ex,但vim也理解+
When you quit the editor, you get back into gdb
.
当您退出编辑器时,您将返回到gdb。
This allows you to browse the source freely and is specially powerfull if you have ctags
integration.
这使您可以*地浏览源代码,如果您有ctags集成,它将是特别强大的。
This is a poor-man's built-in one way gdb to vim integration: the main missing thing is setting breakpoints from Vim.
这是一个穷人内置的gdb到vim集成的一种方式:主要缺失的是设置vim的断点。
edit
and center
编辑和中心
edit
does not center Vim by default around the source, so I've created a Python script that does it: How to open the current file at the current line in a text editor from GDB?
在默认情况下,edit并没有将Vim居中,所以我创建了一个Python脚本来实现这一点:如何在GDB的文本编辑器中打开当前行的文件?
Breakpoint command to clipboard helper
对剪贴板助手的断点命令。
This vim command copies a breakpoint specifier of type:
此vim命令复制类型的断点说明符:
b <file-path>:<line-number>
to the clipboard:
到剪贴板:
command! Xg :let @+ = 'b ' . expand('%:p') . ':' . line('.')
Then you can just paste that into gdb
.
然后你可以把它粘贴到gdb中。
This is a poor man's vim to gdb integration to ease setting breakpoints.
这是一个可怜人的gdb集成vim,以简化设置断点。
#1
65
In contrast with the other answers, there are at least three options that do just what you require: clewn, pyclewn and vimgdb.
与其他答案相比,至少有三个选项可以满足您的要求:clewn、pyclewn和vimgdb。
All three projects are related. vimgdb is a patch against Vim and requires Vim to be recompiled. clewn is a standalone program that communicates with Vim through the Netbeans socket interface. This requires Vim to be built with the +netbeans
option (this is the case in recent Linux distributions so it shouldn't be a problem).
这三个项目都是相关的。vimgdb是一个针对Vim的补丁,需要重新编译Vim。clewn是一个独立的程序,通过Netbeans套接字接口与Vim通信。这需要使用+netbeans选项来构建Vim(在最近的Linux发行版中就是这种情况,所以应该不会出现问题)。
To quote from the clewn's website:
引用clewn的网站:
Clewn implements full gdb support in the vim editor: breakpoints, watch variables, gdb command completion, assembly windows, etc.
在vim编辑器中,Clewn实现了完整的gdb支持:断点、监视变量、gdb命令完成、装配窗口等。
I think you should definitely give it a go.
我想你一定要试一试。
The homepage of the pyclewn website shows a comparison between the three projects.
pyclewn网站的主页显示了这三个项目的对比。
A few months ago I tried pyclewn. It was a bit difficult to set up, but it looks well though out and promising. I just did some tests and you could set bookmarks, etc., the usual stuff you would expect from a graphical debugger. I ended up not using it for contingent reasons but I am keen to give it another try.
几个月前我试着用pyclewn。这是有点困难的设立,但它看起来很好尽管外面和有希望。我只是做了一些测试,你可以设置书签,等等,你可以从图形调试器中得到的通常的东西。我最终没有因为偶然的原因使用它,但我很想再尝试一次。
#2
12
Vim is a nice editor, but to do debugging I use a debugger (like GDB).
Vim是一个很好的编辑器,但是为了进行调试,我使用了调试器(如GDB)。
But you don't have to use GDB in text mode; you can use a graphical frontend like KDbg, DDD or Insight.
但你不必在文本模式中使用GDB;您可以使用图形化的前端,如KDbg、DDD或Insight。
There are ways of getting GDB into Vim (but then you do get text based debugging).
有一些方法可以将GDB放到Vim中(但是您可以获得基于文本的调试)。
#3
3
Using a source level debugger is only one of many ways to diagnose faulty program behavior, and I rarely find myself launching one -- despite the fact that it is very easy to do.
使用源代码级调试器只是诊断程序错误行为的众多方法之一,我很少发现自己启动了一个——尽管这很容易做到。
So for me, there is simply no inherent advantage to using a text editor that happens to also be a debugger. Instead, I use the text editor that I prefer -- independent of what debugger I choose to use. At the moment, I mostly use gedit and kdbg for these purposes, but these choices evolve independently over time.
因此,对于我来说,使用一个碰巧也是调试器的文本编辑器并没有固有的优势。相反,我使用我喜欢的文本编辑器——独立于我选择使用的调试器。目前,我主要使用gedit和kdbg来实现这些目的,但是这些选择随着时间的推移而独立地发展。
#4
1
Having just recently worked on an application for a long time that required a bunch of stuff to be in place on the box it was running (appliance set up), I wrote code in vim, had scripts which automated building, pushing it to a server, which had a script there to notice the sentinel file pushed along with the binaries. This would then restart the appropriate services on the box, and in another ssh window I had a tail -f
running on my log file.
最近刚刚在申请工作很长时间,需要很多东西在盒子里运行(设备设置),在vim中我写的代码,脚本自动化建筑,推到一个服务器,它有一个脚本需要注意哨兵文件和二进制文件。然后,这将重新启动框上的适当服务,在另一个ssh窗口中,我的日志文件上运行一个tail -f。
Long story short, I didn't use a debugger at all. If I had something die unexpectedly, I'd just bump up logging levels, redo it, and see what was the last thing logged before it died, then analyze that and fix the issue.
长话短说,我根本不用调试器。如果我意外地死掉了,我就会提高日志级别,重做它,看看在它死前最后记录的是什么,然后分析并修复这个问题。
The nice thing was that when something had problems in a customer environment, I'd just ask for a Debug-level log and could identify the issue without even requiring access to their server.
好在当客户环境中出现问题时,我只需要一个调试级别的日志,就可以识别问题,甚至不需要访问他们的服务器。
... but yes, there were times when it would have been nice to have a debugger.
…但是,是的,有时使用调试器会更好。
#5
0
GDB edit
command
GDB编辑命令
Opens an editor on the current line using the command:
使用以下命令在当前行上打开一个编辑器:
$EDITOR +<current-line> <current-file>
The default editor
is ex
, but vim
also understands the +<current-line>
format.
默认编辑器是ex,但vim也理解+
When you quit the editor, you get back into gdb
.
当您退出编辑器时,您将返回到gdb。
This allows you to browse the source freely and is specially powerfull if you have ctags
integration.
这使您可以*地浏览源代码,如果您有ctags集成,它将是特别强大的。
This is a poor-man's built-in one way gdb to vim integration: the main missing thing is setting breakpoints from Vim.
这是一个穷人内置的gdb到vim集成的一种方式:主要缺失的是设置vim的断点。
edit
and center
编辑和中心
edit
does not center Vim by default around the source, so I've created a Python script that does it: How to open the current file at the current line in a text editor from GDB?
在默认情况下,edit并没有将Vim居中,所以我创建了一个Python脚本来实现这一点:如何在GDB的文本编辑器中打开当前行的文件?
Breakpoint command to clipboard helper
对剪贴板助手的断点命令。
This vim command copies a breakpoint specifier of type:
此vim命令复制类型的断点说明符:
b <file-path>:<line-number>
to the clipboard:
到剪贴板:
command! Xg :let @+ = 'b ' . expand('%:p') . ':' . line('.')
Then you can just paste that into gdb
.
然后你可以把它粘贴到gdb中。
This is a poor man's vim to gdb integration to ease setting breakpoints.
这是一个可怜人的gdb集成vim,以简化设置断点。