📜 ⬆️ ⬇️

Speeding up work with Emmet, or my first step to open source

Without pretending to innovation and a special depth of reasoning, I decided to write this article with two goals:

  1. To tell about my first experience in writing something useful for the IT community (and specifically, a plug-in for the Sublime Text editor). Perhaps this will encourage the creation of open-source projects of those who have never done this before, are embarrassed, afraid that there is not enough qualification or that it is necessary to write something global, etc.
  2. To show to the coders, the plug-in created as a result, which may well save them precious moments of life.

Let's start by crossing.

1. Part one, with reasoning


Guys, I felt ashamed this month. Not as embarrassing as it happens when something blurted out too much. And just globally. I suddenly realized that I was a useless element in the IT industry. I realized that all my life I had enjoyed the gifts of open source, without offering anything at all to the community myself. Shaped parasite.

And the main reason for this is in my strange certainty that my knowledge is not enough to write something useful for others.
')
So that you understand, I am a coder, or, as it is now fashionable, gardening, "fronder". But no, still a coder. I will not for all engage in self-deception. It can be said that I have been stuck in this specialty for several years, knowing everything else (languages ​​and programming methods, various frameworks, databases, etc.) at the level of applied tasks and not very systemically. But, nevertheless, I can write simple programs and, anyway, do it all the time.

Well, returning to my problem - I felt ashamed. It is known that this feeling in all those who do not suffer from mental illness, first causes sadness, longing, and then the desire to change. When I got to the second stage, I discovered incredible discoveries for my narrow view of the world.

I can already hear your voices: “Share them with us, Captain!”

And the captain does not mind.

OPENING FIRST: colleagues to simplify the work do not always need something revolutionary-global, as I somehow thought, sometimes a fairly small tool that helps in a narrow sphere and is completely “lifted” by me. And the problems that can be solved with such tools are full.

OPENING SECOND: do something useful for people, put it on public display - it is unrealistic to kick yourself to professional development.

Yes, yes, I clearly understand that most of the people reading this text came to these thoughts at the beginning of their careers, and there is nothing new here. But if at least one of you is like me and so far is only leaning towards similar conclusions, then the words are not wasted, and I have the moral right to continue the story.

And now, actually, about what was my first step in the world of professional altruism.

2. Part Two, with ideas


And so I sat down at my first open source. What is useful to write to me first? Another jquery slider? Or some kind of “unlike anything” bootstrap-like framework (frankly, I can't imagine why they are being bred in such numbers now). The idea did not want to suck from the finger.

And I thought about what is missing now personally for me. As you remember, I make up, and how many designers (if not all) use the Sublime Text editor and the wonderful plugin Emmet . He at times makes it easier to write html-markup and css-styles. But, for our needs, let's stop at his work with styles.

Usually my work with the plugin looks like most: when I want to write any css-property, I write its Emmet-abbreviation, press Tab, the abbreviation opens into a normal property, at the end I switch to a new line with the Enter key. This process has, as they say, entered into the fingers and, it seems, everyone is happy with everything in it.

But every time I press Tab -> Enter I suddenly found it superfluous. Why not write down the abbreviations in a row, through the gap, which is much faster, and then reveal them all? It may seem that this is “saving on matches”, however, my experience shows that we usually write properties not one by one, thinking after each, but logical groups, for example, position usually follow left and top, the values ​​of which we already know and can write them in a row without pauses, or when we write width - then we already know what will be further height. And there are many such examples. So there is a good start to reduce the amount of unnecessary gestures.

Emmet itself has its own implementation of this behavior: if you write a value through the “+” sign and at the end click on Tab , they will all open at once. But to constantly reach for a plus, and even with shift, it seemed uncomfortable to press it, and I decided to organize the behavior I needed with a separate plug-in. This went beyond my initial competence, the plugins for Sublime are written in Python, with which I was familiar rather superficially. But, as the ancients used to say, war is garbage, the main thing is maneuvers.

3. Part Three, with results


This is what my work now looks like with the use of the EmmetOneLine plugin written by me:
image

As you can see, Emmet's logic is preserved, everything is revealed as it should, and there are no more tabs and transitions to new lines. Lepota.

I defaulted all the blocks by default on Ctrl + Tab , in the future I think to fasten the check of the string to several properties and make an expansion on the tab when available. It will also be needed by those who use Ctrl + Tab to navigate through tabs. (I usually use fuzzy document search for this).

The plugin was written by me in a few hours, at night, in a fit of inspiration. API Sublime turned out to be quite friendly, there were a couple of articles on Habré and several foreign materials on this topic, things were going fast, since logic was not really confused. To my mind, I must say, to pleasant surprise, I had enough of a general idea about Python, a little programming experience in other languages ​​and a few practices from other plug-ins to make the first working version suitable for use. For the purpose of publishing, I got myself an account on GitHub, which I had not done before, using only BitBucket in work projects. The process of publishing a plug-in to Package Control, so generally turned out to be elementary, it was enough to fork the package_control_channel project and add information about the plug-in to one json file and give it to the maintainer.

Now my little plugin is online and ready to save you time. And I got an interesting experience, energy for the completion of the plug-in and plans to increase the complexity of future open and not only projects.

4. A few words in the end


Summing up, I really want to wish those novice developers who have never written anything for the community to do as I do and just start doing it. Open Source is not always something complicated, there is a need for small, simple solutions. You should not, like your humble servant, be ashamed for so many years of not knowing any questions, the level of English, practical skills, and closing this interesting world for yourself. Find an interesting problem for you and decide on the level at which you can. People will understand you and, if the project is useful, correct the code and help with advice.

For which, by the way, I would be very grateful to dear more experienced colleagues! I would be glad to any help or criticism of the work or the description of the plug-in (including with regards to errors in the English description of the work of the plug-in).

For this, let me take my leave and wish everyone professional growth!

Link to plugin.

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


All Articles