tags:

views:

144

answers:

7

Having just moved from textmate to vim I'm curious. To be able to navigate my project efficiently I've installed command-t and ack.vim. These both seem like relatively new projects in the history of vim. What do people traditionally do to move around a project when they work in vim, do they just use the file explorer or is there some old school trick I don't know about?

+2  A: 

Many people just use the normal file explorer in the bash command line or Windows Explorer or whatever and open files as necessary. For navigating existing source trees, cscope and ctags are both very useful. I find the project plugin really useful for IDE-like navigation of projects and files: it tends to be the main way I navigate my source tree. Combined with ctags, cscope, command-t and ack, navigation can generally be very fast.

Al
+5  A: 

I use NerdTree and I can manage almost everything with it.

kfl62
+1  A: 

"Traditionally?" I've used :Sex for years. That and tab-completion for file-names doesn't make it that bad. Even in directory nestings 8 or 9 deep, using /mo to jump to the directory "models", hit then o to open it... etc etc.

I have installed Command-T on one machine, which is nice, but nothing beats the reliability of netrw

sleepynate
can you "flatten" directories with :Sex ?
mb14
Not sure what you mean... but it is a standard file explorer... you see one directory at a time.
sleepynate
+3  A: 

What I'm using generally:

  1. For opening new files: :e with tab-completion, or :Ex (open explorer in the directory of current file).

  2. For jumping between files in the buffer list (:ls): the taglist plugin, or :b and its tab-completion. Note that for :b, tab-completion works for substrings. For example, if you have two files in buffer list: module.h and module.cpp, you can type :b cpp and tab will complete module.cpp. Very handy!

For tab-completion I also recommend the must-have wildmenu (:set wildmenu :set wildmode=full)

François
+1  A: 

I also only use the basic file and buffer commands for managing my projects. However, I found the following plugins make things easier as well:

  • Fuzzy Finder ( makes opening files more pleasant )
  • NERDTree ( already mentioned, does a nice directory explorer view )
  • Taglist ( useful for navigating in a file )
  • alternate.vim ( useful for programming languages such as C++ with corresponding file types .h and .cpp )
  • MiniBufExplorer ( makes keeping track of buffers easier )

Also, simply remapping :bn and :bp to something easier makes switching buffers more pleasant. For example: and

Lastly, it wasn't mentioned but it is related to project management type stuff, make sure to check out the built in compile-edit stuff

  • :help quickfix

I find that a lot people first coming to vim do not notice it right away.

Neg_EV
The examples in the paragraph starting with "Also, simply remapping ..." are missing. Would you please fix that?
Yaser Sulaiman
+1  A: 

I set path properly then use find for most things. Sometimes I just rely on the tags. The tags allow tab-completion, but find does not.

in my vimrc:

set path=src/\**;c:/work,scripts/\**;c:/work

then

:find foobar.cpp

Will turn up foobar.cpp if it exists under a src/ folder somewhere around my current directory (recursing up to find it until c:/work is hit) and then check the scripts hierarchy.

:tag FooBar

just jumps me right to the definition of that class, as I use ctags to tag my C source code and I also wrote a script to generate tags for an in-house DSL.

dash-tom-bang
This is the best workflow I've heard so far. I see there is an rtags project for ruby so I'll give that a look.
opsb
+2  A: 

Honestly? I rarely open a code file by name. For the most part I use ctags with ctrl-] to navigate around the files (following through to definitions between files), along with ctrl-t, ctrl-i, and ctrl-o. On the rare occasions I want to open a file by name, that's what a shell/explorer window is for.

jkerian
I haven't come across ctags, I'll have to take a look.
opsb
@opsb: This question http://stackoverflow.com/questions/563616/vim-and-ctags-tips-and-tricks might be relevent if you're looking at ctags.
jkerian