0

I am still using Sublime Text a lot more than vim and when using vim, I use it directly from within my terminal for small tasks.

I wanted to make the next step and jump purely to vim and had a look at the graphical vim (in my current case macvim).

When I use sublime I, I can simply open a folder and everything is loaded. How do you guys use the graphical vim quickly and open whole projects?

What are your workflows?

Update

I know that this is a pretty subjective questions, probably with no real definite answer. Anyway I am thankful for all the input I am receiving to get me started and prepared for the vim world!

1
3

Vim is a text editor not an IDE. Having said that vim is highly configurable, and can be customized per individual and usually is, but can be used as an IDE. (there are purists out there too)

Vim can be customized to do more with plugins, and the all mighty .vimrc file. This leads to very individualized vim experiences and no two vims are identical (well, at least for very long).

But most setups follow along this general structure:

  • A Plugin manager of your choosing (pathogen, Plug, vundle, etc) or install plugins manually
  • A plugin for the file tree (NERDTree)
  • A plugin for language specific syntax highlighting (not always needed, default syntax highlighter is pretty good)
  • A plugin for auto-completion (omni-complete)
  • A plugin for file search (ctrlp)
  • any other plugin that you feel is necessary to complete your tasks
  • all fine tuning can be done in your ~/.vimrc file

The suggestions above are not the only ones that exist but are the ones that I use / have used, you should find ones that suite your needs best

If you are trying to start using vim as your main editor the path I would take is the following:

  1. Use vim as is... figure out what you actually need
  2. RTFM on vim and its config file, and see if what you want can be easily achieved via a few simple mappings.
  3. If a simple mapping cant handle it search for a plugin to do what you need and install it.
  4. If you find that you are downloading a lot of plugins then get a plugin manager
  5. Repeat steps 1-3 as needed
  6. If you are too lazy to do 1-5, or just want something now

    a) google vim dotfiles or dotfiles projects

    b) google setups like spf13, dotvim, janus

    c) then trim the fat.

NOTE: A good rule of thumb to follow while editing your vimrc: Don't put anything in your vimrc you don't understand. This helps for several reasons to list a few though:

  • keeps you safe
  • helps to keep your vimrc lean
  • keeps you educated

A good place to start can be found here

1

I think what you're looking for is sessions. :help :mksession

I use vim-obsession to auto load sessions when I enter a directory. I don't know how it would work with gvim, though.

As Peter mentioned, Vim has no concept of "projects". But, I would argue that the concept of a "project" is very subjective. My idea of a project is any directory that has the .git directory in it.

2
  • Since you are using vim-obsession you may want to look at vim-prosession which leverages obsession to make switching between sessions a bit easier. If switching between git roots is your thing there is a post on the subject. Apr 20 '16 at 15:51
  • vim-prosession looks pretty useful, thanks! I live in the terminal, so my "workflow" is to have one tmux tab per project. I feel it's easy enough to cd into ~/dev/lang/project or ~/dev/company/project that I don't need to complicate it with scripting. The bonus is that new tmux panes start in the project directory.
    – Tommy A
    Apr 20 '16 at 19:19
0

Vim doesn't know what a "project" is but it knows what the "current directory" is and that's usually enough.

By default, the current directory is the directory in which you started Vim.

  • If you started the MacVim GUI by double-clicking on the icon or via Spotlight or whatever launcher, the current directory is $HOME. You will need to :cd to the right directory.
  • If you double-clicked on a file associated with MacVim or used the "Open with…" contextual menu, the current directory is the directory containing your file, which may or may not be what you want. You will also probably need to :cd at some time.

FWIW, the behavior is the same on all platforms with all GUI front ends, which are all after-thoughts, really. Vim is first and foremost designed for the shell.

That said, I've used this droplet for years, now, to start Vim from the finder with the right "current directory". The effect is the same as $ vim . in your shell, which is AFAIK the closest equivalent to Sublime's behavior.

1
  • 1
    > Vim is first and foremost designed for the shell. The only problem I have is that the shell vim is scrolling stutterly (iTerm2 and Terminal: tried vim and neovim) whereas the Gui vim (macvim) scrolls super fast without any visual problems.
    – lockdoc
    Apr 21 '16 at 6:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.