📜 ⬆️ ⬇️

Vim in full: Introduction

Hi, Habrayuzer!

For the second year now I have been an active user and a fan of Vim. During this time I have gone from two commands to .vimrc , to a file of several kilobytes and back. I tried a lot of plugins, as well as actively writing my own, and now this is my main text editor for work and leisure.

In this series of articles, I decided to share my own work and, perhaps, show what this editor can be capable of in the hands of a programmer. The series will consist of the following parts:
  1. Introduction (vim_lib)
  2. Plugin Manager without fatal flaws (vim_lib, vim_plugmanager)
  3. Project level and file system (vim_prj, nerdtree)
  4. Snippets and File Templates (UltiSnips, vim_template)
  5. Compiling and doing anything (vim-quickrun)
  6. Work with Git (vim_git)
  7. Deploy (vim_deploy)
  8. Testing with xUnit (vim_unittest)
  9. The library on which everything is kept (vim_lib)
  10. Other useful plugins

I would like to immediately note that I do not pursue the goal of “putting as many people as possible on the Vim needle”, since the article is intended more for experienced users than for beginners.
')

What's wrong with Vim plugins


The main problem of the editor (except for VimLanguage) is a huge variety of plug-ins for all occasions. It would seem that in this bad? The fact is that plug-ins are written by a huge community, from which they are extremely poorly connected to each other. Often, you may encounter the fact that one of your plug-ins is partially able to do the same as the other two, simply because the author of this plugin decided to add more "buns" to it. If you look into the code of most plugins, you can find a lot of duplicate solutions and algorithms from the plug-in to the plug-in, which should be rendered either in the VimLanguage or in some single library. Unfortunately, some plugin authors try to implement these libraries, but after a few simple plug-ins created on the basis of these libraries, they stop supporting and in addition to a dozen not-so-different plug-ins, you need to install a couple of libraries.

When I started developing under Vim, my main goal was to write a single library (yes, another standard) for all my, and most importantly, foreign plug-ins. A distinctive feature of my idea from others was that I was going to implement all the main plug-ins based on this library, and if there are ready-made solutions, then bring them to the library standards. In other words, I want to implement the whole "gentleman's set" of plug-ins that will dock with each other "out of the box" and use a single library.

Two years of work


I began my movement towards “pure and beautiful” by writing a library. I rewrote it as much as three times, because I needed to thoroughly understand all the subtleties of the VimLanguage, its capabilities and limitations, and I can tell you there are a lot of them! The result was the vim_lib library, which completely satisfies me.

A feature of the library is that it defines the structure of the editor as a whole (as a framework), adding a new level of action of scripts - project. In fact, this allows you to customize your editor for a specific project and even install plugins that will only work in this project. This is especially useful when working with multiple PLs.

Here is a small example. Suppose we work with a web project using PHP and JavaScript, and in our free time we write a book using LaTeX. What can I offer you and Vim:



Experienced Vim users will say: “Pff ... For all this, there are a bunch of ready-made plug-ins. Bike! ”- but you just don’t know what my proposed solutions are capable of. Not only do they easily fit together, they are also more functional than their counterparts among Vim! In this you can be sure of the following articles of the cycle, just have patience.

What if you can't wait


I accompany almost all my plugins with detailed documentation, so you can try them now. Here is a list of solutions implemented to date:



To install, create a directory ~ / .vim / bundle (you can use any name) and copy vim_lib there.
 git clone https://github.com/Bashka/vim_lib.git ~/.vim/bundle/vim_lib 

Then add the following entry to your .vimrc :
 filetype off set rtp=~/.vim/bundle/vim_lib call vim_lib#sys#Autoload#init('~/.vim', 'bundle') "    ~/.vim/bundle Plugin 'vim_lib' "   filetype indent plugin on 


In general, everything is as usual.

Bye all


I support this project on days off from work, correcting the bugs found during the week and adding the functionality that I needed in the process. If you have any suggestions, what would you personally lack in Vim, go through the survey, and sooner or later it will be implemented as another plugin for Vim.

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


All Articles