Vim Tips Wiki
No edit summary
Line 22: Line 22:
 
* minibufexpl {{script|id=159}} plugin, which will allow for tabs of all your files (works really well).
 
* minibufexpl {{script|id=159}} plugin, which will allow for tabs of all your files (works really well).
 
* project.tar.gz {{script|id=69}} plugin, gives you a "project" view of files, rather than a straight file system view
 
* project.tar.gz {{script|id=69}} plugin, gives you a "project" view of files, rather than a straight file system view
* indexer.tar.gz {{script|id=3221}} plugin, indexes all files in project automatically. Using ctags. Can work as add-on for project.tar.gz, but also can work independently.
+
* indexer.tar.gz {{script|id=3221}} plugin, indexes all files in project automatically and keeps tags up-to-date. Using ctags. Can work as add-on for project.tar.gz, but also can work independently.
 
* snippetsEmu {{script|id=1318}} plugin, gives you a sort of code completion
 
* snippetsEmu {{script|id=1318}} plugin, gives you a sort of code completion
 
* AutoComplPop {{script|id=1879}} plugin, gives you code completion
 
* AutoComplPop {{script|id=1879}} plugin, gives you code completion

Revision as of 15:40, 12 November 2010

Tip 1119 Printable Monobook Previous Next

created 2006 · complexity intermediate · author Matt Zyzik · version 6.0


I use Vim for all text editing, even software development. At one point I stopped using IDEs. One major reason is that Vim can do all the major things I need from IDEs (tabs, file trees, greping, syntax highlighting, indentation, completion, "quickfix"ing, etc).

Still Vim needs plugins to do some IDE-like things that aren't built in. Here are some Vim scripts that make Vim more like an IDE.

  • NERDTree script#1658 plugin
  • vtreeexplorer script#184 plugin
  • taglist script#273 plugin, which gives you an outline of the source you're viewing
  • bufferexplorer script#42 plugin, lets you navigate through open buffers
  • minibufexpl script#159 plugin, which will allow for tabs of all your files (works really well).
  • project.tar.gz script#69 plugin, gives you a "project" view of files, rather than a straight file system view
  • indexer.tar.gz script#3221 plugin, indexes all files in project automatically and keeps tags up-to-date. Using ctags. Can work as add-on for project.tar.gz, but also can work independently.
  • snippetsEmu script#1318 plugin, gives you a sort of code completion
  • AutoComplPop script#1879 plugin, gives you code completion
  • matchit script#39 plugin, improves % matching


See function Kwbd in Deleting a buffer without changing your window layout which allows you to delete a buffer without actually closing the window.

Comments

For debugger integration, try http://clewn.sourceforge.net/ or http://jaredforsyth.com/projects/vim-debug/


What about refactoring? Say you need to reorder the parameters of a function, which means that all calls to that function must also be reordered. Can Vim do that?

A quick search turned up the following:
A more involved search may turn up more. If you find something you like, feel free to add a section to this tip mentioning it. If you still need help, try the vim_use mailing list or the #vim channel on Freenode. See our advice for asking questions for some options.
--Fritzophrenic 15:59, February 24, 2010 (UTC)

For when you're stuck with Visual Studio: see ViEmu at http://www.ngedit.com/viemu.html


Code navigation in vi offers much more than a standard IDE, because of the ability to execute the desired combination of commands. Generate an index much more rapidly than an IDE with a heavy GUI interface:

For example, one can take advantage of the tag stack:

For C++, follow the instructions: on using OmniCpp Define a custom .ctags file

--c++-kinds=+p
--fields=+iaS
--extra=+q
--language-force=C++

From a console (the exclude options may vary) generate the tags file as follows:

  ctags --exclude=.svn --exclude=target -R .

Configure options in the vimrc to navigate. Some IDE's use F5 to step in, F7 to step out, and one of the nice features of vi during code navigation, which is unavailable in other IDE's is to see a stack at the bottom of the screen (if the menu bar has been enabled and the new window is maximized) of how one got to the current class file. Also, in C++ it may be useful to tab back and forth between the cpp and h files (shown below with a ctrl key for F5 and F7). Some IDE's do this with a ctrl+tab sequence, perhaps vi could be configured for that.

map <F5> <C-w>g]
map <F6> <C-w>_
map <F7> :pop!<CR>:q<CR>
map <C-F5> :e %:r.cpp<CR>
map <C-F7> :e %:r.h<CR>