📜 ⬆️ ⬇️

Vim and IDE are different things.

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

In essence, the article will be a detailed explanation of the idea expressed by another user in the commentary on the article “VIM: why, if there is an IDE, and how?” .
Fundamentally, the IDE differs from the editor in that the IDE operates with the syntax tree of the edited code in the target language (or some 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, not 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 the article Introduction to Microsoft “Roslyn” CTP
In the past, our compilers worked as black boxes - you submit the program source code to an input, and you get an assembly at the output. All the knowledge and information that the compiler generates is thrown away and inaccessible for anyone's 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, up-to-date and manageable code, our team can be more productive, innovate faster and deliver more features faster and with better quality.

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

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


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

Vim


The vim task is text editing. Everything. Point. Seriously. And now I will explain what I mean.

The main feature of vim is “understanding” of the elements of the text: word, line, sentence, paragraph, etc. Vim at the lowest, simplest level is designed to work with text. Just try to work in vim without add-ons and even without syntax highlighting. I assure you, it will be an unforgettable experience.
It seems that something similar sounded in the Hexlet webinar about vim: www.youtube.com/watch?v=79OWQ1qJwto .

But this is also the main difficulty in mastering vim - you have to think in terms of vim. For an IDE, this is not a problem - we are learning a 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 mind guides. I used to think:

It is necessary to go to this line or to this place in the code. And the mouse put the cursor in the right place. Now it looks a little different:

We must go to this line. Hmm ... To the nearest site with the announcement of the public method. / public
Delete three words 3dw

All this looks quite inconvenient at the first stage, but then allows you to do complex things with relatively simple actions. For example, if I have a log, I can delete with one command all the lines that do not contain the word "Exception".

In addition, it allows the use of 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 “advantages” of vim, so I turn to the conclusion.

Together


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

Plug-ins to simulate different IDE functions are an attempt to combine two tools. Just like IDE plugins that mimic vim work.

You can go the hard way and try to make an IDE from vim'a. You can go a simpler way and add some of the capabilities of vim to your favorite IDE. Or you can go the simplest 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 simple text.

findings


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 some kind of API (as is done between the IDE and the Roslyn compiler). So that the IDE can embed any editor that is most suitable for working with text.

Source: https://habr.com/ru/post/304832/


All Articles