Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Vim defaults to being a C IDE, no plugins required. The features I called out above are available with no plugins.


Interesting, didn’t know, will try it. Does it do “jump to definition” out of the box?


Sure does. :) `gd`


probably "gD" is what you want unless you're looking for a local definition.


:gd

E492: Not an editor command: gd

VIM 8.2

Do I have to activate it somehow? :)


Have the following file:

    int foo ()
    {
        return 3;
    }

    int bar()
    {
        return foo();
    }
put your cursor somewhere on the "foo" identifier in the second to last line and type "gD" (without the quotes). It should jump to the definition of foo. It's not perfect but works for much code without crazy preprocessor stuff. By default it's file-local, but you can give vim a list of include files to search as well.


Ah, upper case D, yep that works! Thanks!


yeah lower-case "d" is for local definitions (it just searches for the first appearance in the "[[" region if you are familiar with vim motions).


What aidenn0 said.

Specifically it's one of the 'g' commands (like gg which goes to the top of the file and gG goes to the bottom). Just put your cursor on an identifier and gD (goto definition is the mnenomic).

:help g


So the days of using ctags are long gone?


No, you still need ctags to jump to sources outside of your current file. But within the same file, it works fine without it.

C doesn't have a defined directory structure, and a lot of the source/header files you'd use are stored in places like /usr/lib and such.


Yeah, but that is the thing, an IDE works with more than one file.


I feel like you're taking my words in bad faith.

Vim works perfectly fine with multiple files out of the box, it just wants a tag file for jumping between multiple files and letting autocomplete work with those tags.

This is hardly unique to vim (and emacs) - you can't work on a project in IntelliJ without first setting up a workspace and letting IntelliJ index all those files. The only difference is how the index is generated.

Oh, and `:help cscope` (again, thanks aidenn0). In vim >=9.0 a tagging tool is now incorporated into the base vim install.


Nope, just making the point that vim has lots of things to catch up with a proper C IDE in a default install.

ctags was just the first example of many things I can refer to.

For example any basic C IDE on a default install is expected to have debugging integration, project management, among other stuff.


I'm so confused. Vim has ctags, and it works, across multiple files.

Granted I don't think vim is an IDE, but you'd demonstrate that better by pointing to the IDE stuff it doesn't do (like debugging, I think, but I debug with printf and only rarely fire up gdb so for all I know it does support it).


Op thinks it is one,

> Vim defaults to being a C IDE, no plugins required


Right, but ctags isn't the reason it's not. Ctags just works and goes substantially above and beyond what you'd expect of "Just a text editor".


Note that cscope is significantly better than ctags and also built into vim.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: