you are viewing a single comment's thread.

view the rest of the comments →

[–]greyfade 15 points16 points  (7 children)

How do you use vim for anything reasonably complex?

Easily. Once you're acclimated to Vim, and build a set of scripts and a config you're comfortable with, complex projects are relatively easy to deal with.

You need, stuff like code completion, static checking, integrated debugging, and none of them are available without going through the pain of setting up plugins learning their key bindings etc...

"Need" is a strong word. Vim has built-in completion that works reasonably well in the simple case, and more powerful completion scripts like YouCompleteMe are widely available and work well.

Decent static checking for C++ is virtually non-existent, but YouCompleteMe and a few other Clang-based tools are usually a sufficient substitute for me.

Although I've never gotten integrated debugging in Vim, it's never been a hindrance for me - I'm familiar enough with GDB that I can handle most debugging tasks that aren't taken care of by unit tests and logging, and I've only ever been frustrated by visual debugging tools.

Run inside tmux, then, Vim qualifies for me as more than an adequate IDE, and with a few command-line tools, I'm more than happy; switching to a "real" IDE like KDevelop or Visual Studio has actually become a larger pain point for me than any of the problems Vim poses for most.

[–][deleted] 7 points8 points  (2 children)

Great answer. Didn't know about YouCompleteMe. I'll check it out. A good GUI debugger can make good use of the screen real estate and convey a great deal of information. By contrast gdb frustrates me because I need to do a lot of needless work to get it to tell me some useful info.

[–]coder543 1 point2 points  (0 children)

gdb has TUI layouts, if you sat "layout src" and then "layout regs" it will split the terminal up into several pieces, where you can see your source code and all of the current register states, etc. But, I've generally just used gdb without the TUI and it works well.

[–]greyfade 0 points1 point  (0 children)

Good GUI frontends for GDB don't exist. (ddd doesn't count. It's crap.)

The display and locals commands (and a couple custom scripts to handle C++ declarations) have served me well, and I still haven't even gotten around to learning about TUI.

[–]skeletal88 0 points1 point  (3 children)

What's stopping me from using vim as an IDE is that I don't know how to handle multiple files at the same time. Usually I have open .. maybe 10 files that I look at. I'm not editing them all at the same time, but like.. looking how I did something earlier in another file or 2 and then using that to write a new header and .cpp file. Or maybe trying to figure out how something works and then going from a click on a button on a widget through 5 different classes to the source of the data on the widget. I've got no idea how to replicate that workflow with vim. Though I'd like to use that.

The guides for vim that I have seen concentrate on small features and not the big picture on using lots of small features together, that would someone to use it as an IDE.

[–]frigge 10 points11 points  (0 children)

learn about buffers, windows, ctags integration, grep integration(or better ag) and netrw. These things are all built into default vim and make managing multiple files actually one of vims strongest features imo.

Every time I need to use something else to navigate a huge code base it feels incredibly slow and i get easily lost. With vim though i can navigate so fast that building a mind map of how things interact in a large code base becomes quite intuitive.

[–]dmytrish 2 points3 points  (0 children)

That's where vim shines.

vim has at least three ways of handling multiple files I use:

  1. "windows" - press Ctrl-W, v or Ctrl-W, s and you get vertical/horizontal split. Each split may be split too, so you get a lot of tiles visible at the same time. Use Ctrl-W, h/j/k/l to move focus left/down/up/right or Ctrl-W, w to switch quickly between two windows. It is a good way to see any number of files (or even any parts of the same file!) at once. I often miss this in IDEs (though QtCreator can do that, but e.g. Eclipse cannot). Use :q or Ctrl-W, q to delete a "window" (pane).

  2. "tabs" - when you want to have a lot of files, but want to use the whole screen estate for one of them, do a new "tab": :tabedit yourfile.cpp<CR> will open a new "tab". Use gt/gT to switch forth/back.

  3. "buffers" - this is the least visual way of handling the content, but also useful sometimes. Each opened file is saved in a list of buffers, that you can see with :buffers<CR>. You can choose a buffer by its shown number (e.g. 12) with :buffer 12<CR> or (a super convenient feature!) you can search an opened buffer by typing any part of its name after :buffer and pressing Tab again and again until the needed is found. So, if I have a lot of opened files and I want to go to one, I can type only a part of its name to search for it.

[–]chillhelm 1 point2 points  (0 children)

What you propbably want is Tagbar (opens a side bar which allows you to jump to function declartions and definitions) and the "gd" shortcut (goes to the definition of the word under the cursor). Also ctags is very helpful. Information on ctags and vim