Learning to use the vim editor for development

Hi Guys!

I see a similar topic about vi for writing novel. And I want to ask your experience to a every-day development process usin only vim as editor.

My question are:
1. Project files tree, how do this in vim?
I'm found plugin NERDTree, but not understand how create files, or maybe how to use it at all. Show please your usual interacting with that plugin if you use it.

2. Opening several files and navigating througnt it. How to do that? For example if I want to quickly switch to any already opened file?

3. Save state of opened files at exit. Or maybe session management? For example open session with Prog1 and there are all about that project last state.

....Any other your propositions and tricks......


Thanks!
 
Guys, thanks for your answers!

Firstly I want to understand - is it possible to customize editors/vim as a IDE for development, and if not - I will think about other editors. I'm read articles about editors/neovim and will know about it if my investigations in editors/vim fail, but now please tell me about using vim as IDE.
 
I am a bit more of a vi user. But when I am on a platform that only has vim, I tend to do the following:

1. Project files tree, how do this in vim?
I'm found plugin NERDTree, but not understand how create files, or maybe how to use it at all. Show please your usual interacting with that plugin if you use it.
I personally find that I don't want to lose access to the more powerful command prompt. So for that reason I tend to bind keys to jump to the command line (i.e :sh, job control, :term) via control-t. Something like the following:

Code:
nnoremap <C-t> :sh<CR>

Then I will make/remove the directory, file, etc from there.

You can navigate files more easily with :e and then <tab> complete if you set the wildmode to something more akin to the shell behaviour:

Code:
set wildmode=list:longest

2. Opening several files and navigating througnt it. How to do that? For example if I want to quickly switch to any already opened file?
This is where buffers or tabs come in. Again, a simple mapping to display buffers and then let the user decide:

Code:
nnoremap <C-b> :ls<CR>:b<Space>

then I can just hold ctrl-b and press the number relating to the file I want to jump to.


3. Save state of opened files at exit. Or maybe session management? For example open session with Prog1 and there are all about that project last state.
I personally don't. I prefer to resume work with a clean slate, so can't help you here.
 
I have two types of utilities on my plate currently: 1. a simple "parser". 2. a "client/server" thing.

#1 is a single file and a makefile.
#2 is two+ files and a makefile.

In both these cases I open gvim, type away. When I want to compile, I type "term" (which opens a terminal in my buffer), type make, run my program, type exit, and the terminal is closed and I'm back to editing (fixing my errors).

In a more complicated setup (multiple files) you don't work with a "files tree" much (you can, obviously). You use `ctags` to bounce around without having to "open a file" mostly.

`cags` and built in tools like "GF" (go to file) are how I navigate in Vim in the larger projects. Super powerful. When I want to "navigate to 'that' directory and choose the file to open" I use the built in explorer (but this is not very often because that's very clumsy). I've used `Nerdtree` (or at least installed it once) but I honestly think I've used it once or twice in almost 20 years of using Vim.

I *think* there is a "session management" thing built in, but I'd have to look that one up.

File switching: "buffers" is what vim uses and you can switch with `bnext` and whatnot. 'Buffers' are extremely powerful. For example, you can find and replace in all buffers at once.

What type of projects do you plan to work on? If you want to do C development, Vim is built for that.
 
Firstly I want to understand - is it possible to customize editors/vim as a IDE for development,
That's part of my post I deleted, because I thought I misunderstood you, and it wouldn't be helpful to you, so:

Actually I don't know if vi[m] can be turned into some kind of an IDE. But in my eyes this doesn't make sense, 'cause you're going to bloat a tool into something what it's originally not ment to.
Extensions or added features are one things. But converting a bicycle into an aircraft carrier is not a good idea:
You neither have a bicycle anymore, nor a good carrier.

IMO you have 4 options:

a) You may add/extend vim with the possibilties given [besides the mentioned I also found NERDTree, and 11 Best tree explorer plugins for Vim,... I don't know a single one of them, but there shall be some] - and see if you can live with it.
Also vim comes with the possibility of scripting, so the capability to import/write customizations; all I read about was it seems to bloat/slow the editor too much, seems to bring security issues, and seems to be the main reason why neo-vim was started in the first place.
But for sure here are others who could tell you more/right about this.

b) Any half-way professional IDE shall offer the possibility to use another texteditor instead its default installed one; so get you the IDE suiting you, and use vim instead.

c) You may check another Editor. Gedit, and Geany are also good editors, come by default with file trees - they are not vim-, but emacs-like to use.
Or you may use Emacs, for which there is a humongous buttload of extensions; even the possibility to use it vi-style.

I simply remember my emacs-days: could had spent one or the other week just to search, install, try (learn it a bit), uninstall,...,search... for a certain extension. (Worst thing an emacs-newbie may do is to install everything by the very start on emacs - never do that! It's way too much. Always extend emacs only step by step with things you really need/want, otherwise you may drown in the amount, or even worse kill your configured emacs environment, e.g. by some extensions may overwrite your UI-settings [Happend to me once.])

d) You may reconsider your workflow, learn and adapt yours to another, maybe a more vi[m]-like-style. Which could turn out to be the way with less effort - may be not.
 
For quickly switching between 4 files I've used harpoon. It's quite simple to use. But it's for neovim only unfortunately.
I actually found Harpoon more useful than having file explorer in neovim.

3. Save state of opened files at exit. Or maybe session management? For example open session with Prog1 and there are all about that project last state.
I know you can do something like this in neovim where you can save it as a session and then restore it. its called auto-session.
 
Back
Top