Vim and IDE are two different things.

I saw another article about vim and IDE and decided to share my thoughts - what if someone seems useful, what the hell is not joking? ..

In fact, the article will be a detailed explanation of the idea expressed by another user in the commentary to the article “VIM: why, if there IDE, and how? " .
Fundamentally, an IDE differs from an editor in that the IDE operates with the syntax tree of the code being edited in the target language (or some kind of approximation to it), and the editor operates with characters and strings.

I start from the idea that vim and IDE are different tools for different tasks. Completely different and, moreover, non-overlapping tasks.

IDE


The task of the IDE is to develop a program in one of the programming languages. The better the IDE "understands" the programming language, the more useful features it can offer the developer. Starting from the most elementary - syntax highlighting, and ending with the most advanced - highlighting potential errors and refactoring.

As an example, consider the Roslyn project and Visual Studio. You can read about it in one old article - Introduction to Microsoft "Roslyn" CTP .

Quote from an article Introduction to Microsoft “Roslyn” CTP
In the past, our compilers worked like black boxes - you submit the source code of the program to the input, and you get the assembly at the output. All the knowledge and information that the compiler forms is thrown away and inaccessible for anyone to use.

As Soma writes in his blog, part of the Visual Studio language team is working on a project called Roslyn. Its main goal is to rewrite the C # and VB compilers and create language services in managed code. With clean, modern, and manageable code, our team will be able to be more productive, innovate faster, and deliver more opportunities faster and with better quality.

Moreover, we open the C # and VB compilers with all their internal information, making code analysis available to you. We provide a public API and provide extension points in the C # and VB language services.

This opens up new possibilities for VisualStudio extensions - writing powerful refactoring tools and language analysis utilities, as well as allowing anyone to use our parsers, semantic engines, code and script generators in their applications.


In short, Roslyn is a project that provides an API for the compiler. And this allows the IDE to "understand" the programming language as well as the compiler does.

Vim


Vim's task is text editing. All. Point. Seriously. And now I will explain what I mean.

The main "trick" vim'a - "understanding" of the text elements: word, line, sentence, paragraph, etc. Vim at the lowest, simplest level is tuned for working with text. Just try working in vim with no extras, and even without syntax highlighting. I assure you that this will be an unforgettable experience.
It seems something similar sounded in the Hexlet webinar about vim: www.youtube.com/watch?v=79OWQ1qJwto .

But therein lies the main difficulty in mastering vim - you have to think in terms in which vim works. This is not a problem for the IDE - we learn the programming language, we work in the same terms as the IDE. For vim, this is not obvious. It took me some time to change my mental guides. I used to think:

We must go to this line or to this place in the code. And with the mouse put the cursor in the right place. Now it looks a little different:

We have to go to this line. Hmm ... Go to the next line with the public method declaration. / public
Delete three words 3dw

All this looks rather inconvenient at the first stage, but then it allows you to do complex things with relatively simple actions. For example, if I have a log, I can delete all lines with no “Exception” in one command.

In addition, it allows you to use a system of macros that work in terms of text elements and are more flexible.

You can still write a lot about the possibilities, but this article is not about the "pluses" of vim, so I’m going to the conclusion.

Together


The reader probably had a question: why then all these plugins for vim? If this is not his task?

Plugins to simulate different IDE functions are an attempt to combine two tools. Just like plugins for the IDE, simulating work in vim.

You can go the hard way and try to make an IDE from vim. You can go the simpler way and add some of vim's features to your favorite IDE. Or you can go the easiest way - do not use vim. Using vim gives an additional “mode” of work - when it is more convenient to work with the code as with plain text.

conclusions


I wanted to emphasize that IDE and vim are different tools for different tasks, and their opposition is only that there is no ideal option to integrate these two tools.

In my opinion, the best solution would be if the IDE and the text editor were separate modules that interact through a certain API (as is done between the IDE and the Roslyn compiler). So that any editor that is most suitable for working with text could be embedded in the IDE.

Also popular now: