5 ms·
As always, what loses me on vim is that I'm not sure what's the easiest/best/common way to have a "project directory" open and quickly open one of the files ins
by janus 13y ago
As always, what loses me on vim is that I'm not sure what's the easiest/best/common way to have a "project directory" open and quickly open one of the files inside that directory... no basic tutorial seems to tackle this, yet it's essential to migrate from any other editor you use as a programmer...
- cal2 13y agoI'm not sure if this is what you want, but NERD Tree[1] works for a lot of people. Here's a tutorial[2] for NERD Tree that I quickly found. [1]: https://github.com/scrooloose/nerdtree https://github.com/scrooloose/nerdtree [2]: http://code.tutsplus.com/tutorials/vim-essential-plugin-nerdtree--net-19692 http://code.tutsplus.com/tutorials/vim-essential-plugin-nerd...
- janus 13y agothanks, I'll give it a try. When I briefly tried NERDtree, my issue was how to switch back and forth between the tree and the opened files list
- bitcrusher 13y agohold down control and hit w, twice, when in visual mode. That will move the cursor from frame to frame. If you want to see a 'file browser', open VIM and type ":sp ." Strictly speaking you don't need nerdTree (though I love it ).
- rtfeldman 13y agoYou want CtrlP - it's a plugin that works basically the same way as Sublime Text's Cmd-T. If you want a more familiar Sublime-esque experience, you can also rebind it from Ctrl-P to Cmd-T (which is how I personally use it). So my workflow on a Mac is to type `mvim ~/project-dir-goes-here` and then press Cmd-T just like I would in Sublime to start typing in a filename and see a list of matching files to open. https://github.com/kien/ctrlp.vim https://github.com/kien/ctrlp.vim http://stackoverflow.com/questions/11979313/command-key-in-macvim http://stackoverflow.com/questions/11979313/command-key-in-m...
- sstanfie 13y agoAnother tip, and this one doesn't need a plug-in: If your cursor is on a file name, like "foo.js", you can type gf to "go to that file" for editing. Going back isn't as easy to remember. It's Control-O. So I map that in my .vimrc to gb like this: " gf is built in and will "Goto File" " gb is the opposite, will "Go Back" nnoremap gb <C-o>
- nimrody 13y agoI never navigate by searching for a filename. If it's C/C++ code I use ctags and cscope and just ":tag <function-name>" to go to the function definition (VIM will autocomplete the function name). If it's a Rails project, there's a Vim Rails plugin and then ":Econtroller <controller-name>" opens the relevant file, etc. It's also possible to keep a file listing all of your project files (Or just edit your Makefile if you use one). Then just switch to that buffer, search ("/<blabla>") for the file and "gf" (goto-file - opens the file whose name is under the cursor).
- dllthomas 13y agoI have things set up to easily drop the output of a git grep into my quickfix buffer, so I can step through occurrences across many files in my project.
- modulus1 13y ago:e . Will show a directory listing, you can navigate the directory tree and open files. Particularly useful if you have a shortcut to change the working directory to the current buffer's file path.
- pbarnett 13y agoI use that one all the time! Also, :sp . which splits your window and opens the directory listing in a new buffer.