What is the traditional way to navigate a project

Just moving from textmate to vim, I'm curious. To effectively manage my project, I installed command-t and ack.vim. Both of them seem to be relatively new projects in the history of vim. What do people traditionally do to move around the project when they work in vim, are they just using a file explorer or is there some old school trick that I don’t know about?

+4
source share
8 answers

I installed path correctly and then used find for most things. Sometimes I just rely on tags. Tags allow you to tab, but cannot be found.

in my vimrc:

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

then

 :find foobar.cpp 

Foobar.cpp will appear if it exists in the src / folder somewhere around my current directory (recursively search to find it until c: / work suffers), and then check the script hierarchy.

 :tag FooBar 

just jumps me straight to the definition of this class, since I use ctags to tag my C source code, and also wrote a script to generate tags for my own DSL.

+8
source

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

+4
source

What I use in general:

  • To open new files:: :e with the completion of the tab or :Ex (open the explorer in the directory of the current file).

  • To navigate between files in the buffer list ( :ls ): the taglist or :b plugin and its completion tab. Note that for :b tabs are performed for substrings. For example, if you have two files in the buffer list: module.h and module.cpp, you can enter :b cpp and the tab will end with module.cpp. Very comfortably!

To complete the tab, I also recommend using wildmenu ( :set wildmenu :set wildmode=full )

+4
source

Fair? I rarely open a code file by name. For the most part, I use ctags with ctrl-] to navigate files (after defining between files), as well as ctrl-t, ctrl-i and ctrl-o. In rare cases, I want to open a file by name, this is what is for the shell / explorer window.

+4
source

Many people simply use the regular file explorer on the bash command line or Windows Explorer or something else and open the files as needed. Cscope and ctags are very useful for navigating existing source trees. I find the project plugin really useful for navigating projects and files like the IDE: it is usually the main way to navigate the source tree. Combined with ctags, cscope, command-t, and ack, navigation can be very fast.

+3
source

"Traditionally?" I used :Sex years. This and tab completion for file names is not so bad. Even in directory slots 8 or 9, using /mo to go to the "model" directory, press o to open it ... etc.

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

+3
source

I also use only core files and buffer commands to manage my projects. However, I found that the following plugins make things easier:

  • Fuzzy Finder (makes opening files more enjoyable)
  • NERDTree (already mentioned, has a good view of the directory explorer)
  • Tag List (useful for navigating in a file)
  • alternate.vim (useful for programming languages ​​such as C ++ with corresponding .h and .cpp file types)
  • MiniBufExplorer (simplifies buffer tracking)

In addition, simply reassigning: bn and: bp to something simpler makes switching buffers more enjoyable. For instance:

nmap <Cn> :bn<cr>

nmap <Cp> :bp<cr>

Finally, it was not mentioned, but it is related to material such as project management, do not forget to check the built-in compilation file.

  • : help quickfix

I find that many people who come to vim for the first time do not notice this right away.

+3
source

I understand that it may be too late, but I hope that it would be useful for someone.

We have a relatively large project for working about a thousand files of C / C ++ code, php and shell scripts, configs, and more.

To navigate through the files, I use the following options.

First , I use a simple grep wrapper stored in my .vimrc to find a specific line in the files:

 function MyGrep( pattern, path, case, whole ) execute "normal! GoSearch text " . a:pattern . " in " . a:path . " and subdirs, case: " .a:case. " whole: ".a:whole "E - extended regexp, l - display filenames only, r - search recursively let l:keys = "Elr" if a:case == 0 "case-sensitive let l:keys = l:keys . "i" endif if a:whole != 0 "whole words only let l:keys = l:keys . "w" endif let l:cmd = "r!grep -" . keys . " -e \"" . a:pattern ."\" " let l:cmd2 = a:path . " --exclude=*.ncb --exclude=*.o --exclude=*.d --exclude-dir=.svn --exclude-dir=.d --exclude-dir=rc.d --binary-files=without-match" echo l:cmd . l:cmd2 execute l:cmd . l:cmd2 endfunction com -nargs=1 GrepHere call MyGrep( <q-args>, "./", 0, 0) com -nargs=1 GrepHereCaseWhole call MyGrep( <q-args>, "./", 1, 1) com -nargs=1 GrepHereCase call MyGrep( <q-args>, "./", 1, 0) com -nargs=1 GrepHereWhole call MyGrep( <q-args>, "./", 0, 1) 

In windows, I use vimgrep and changelist with this command (also in .vimrc ):

 command -nargs=1 VGCodeHere :vimgrep /<args>/j ./**/*.{c,cpp,h,rc} | copen 

Both greppers are dependent on the current working directory, so be sure to install it correctly. Usually I open a new unnamed tab in Vim and use the search commands here to dump the file names that interest me, search results, log locations and other information.

Second , the cscope utility and the Vim plugin are a very convenient way to view files, functions, symbols in a project, but if you are dealing with C / C ++ sources.

Third , Vim's own tricks, such as

  • :e ./**/filename.cpp to open the file filename.cpp somewhere in the subtree of the file system. Support for <Tab> file name completion.
  • :tabe %<.h to open the corresponding header file (you can change the .h extension to whatever you like)
  • :Ex for navigation using the built-in file system browser
  • Ctrl-O, Ctrl-I to go back and forth to the Vim jump list.

And to resume the next time from the same Vim state, I use sessions . Save the session in Vim with :mksession sessionname.vis , and start vim with the session: vim -S sessionname.vis

+1
source