|
|
|
|
|
by sjaak
1094 days ago
|
|
I've become comfortable with using vim /within a file/, what I'm having trouble with is using vim while having multiple files open (keeping track of which ones I've saved, switching between them, etc.) My current workflow is to have multiple files open each in a separate terminal tab, but navigating between them Cmd+Shift+[ and ] feels suboptimal. Does anyone have any great tips? I work on Java and Ruby (rails) projects most of the time. |
|
Then I discovered buffers which was life changing. Suddenly I could manageably switch between 10s of files and never really worry too much about closing them. Sessions are helpful too for truly long running editing and maintaining a "workspace".
The buffer pro tips are:
- Use :set hidden
- ^ to switch to last buffer
- Switch buffers with :ls which will stay visible after typing :b and you can switch by number, or you can switch by name with tab completion (even by going straight to :b). So, I can switch to IWouldRatherBeWritingSomethingElse.java with ":b IWo<TAB>".
There are plugins to make switching even easier with fuzzy finding and whatnot but the above is all vanilla vim so you can do all this on some random cloud host anytime. I can't recommend a plugin because before really settling on one, I switched my serious development to Doom Emacs which has very similar buffer semantics and switching bells and whistles.
Check out Drew Neil's awesome Vimcasts to see buffers in action. http://vimcasts.org/episodes/working-with-buffers/