There are times when you want to balance the whole thing after you finish typing the code in Rails. I was absorbed in thinking about the code, and when I looked back, the indentation was scattered and the balance was insanely hard to see. Also, I think there are times when you want to add a parent element later, straddling multiple elements, and you need to indent one space for every row of child elements. As a programming enthusiast, I just kept hitting the TAB key to get rid of the indentation.
Meanwhile, the world has changed since I learned the trick of "rectangle selection". I think many people know it, but if there are people who don't use it or don't know it, I think it's a waste, so I'll share this useful technique.
See the code below. This is the code that created a new user registration screen using devise. This alone can be used as a function, but it does not look beautiful.
I want to use Bootstrap to balance the whole thing
<div class="container">
<div class="row">
I will surround it with.
qiita.rb
<div class="container" >
<div class="row" >
-------------← I want to put the above code here! !! !!
</div >
</div >
I agree. That's fine if you just put it in between, but if you're aware of readable code, it's likely to be more beautiful to indent every line.
But it's a hassle. I understand. In such a case, you can use this "** Rectangle selection **"!
Very useful features are easy to use. For macOS
Keyboard rectangle selection command
Click where you want to start
[Shift] + [Option] + [Command] + arrow keys
Drag as it is
Only this.
To explain it more clearly,
In this way, click where you want to start.
And when you type in the ↑ command,
Fortunately, the pointer has been expanded to enclose the entire <div class = "field">
.
If you can do this, it's easy.
To make it easier to see, if you leave the indent only in the ↑ part, it will look like this.
Yes, it's very convenient.
Of course, you can not only leave a space but also type letters. By typing the character once, I was able to type the same character on the other lines selected by the rectangle. There are many other ways to use it, so if you are interested, please check it out!
I think there are many small tricks in the programming world that can reduce your work time in this way. It's hard to remember everything at once, but if you get used to it one by one, the day may come when you can become a very smart programmer!