T
T
Tash1moto2016-03-30 21:32:17
vim
Tash1moto, 2016-03-30 21:32:17

vim. What are the options to move text?

Hello everyone, I recently figured out vim, set everything up beautifully, it works fine, I'm satisfied.
What is the smartest way to put all the span blocks before the img, in a minimum of operations? how would you do?
Markup example:

<div class="block"><img src="https://d.wattpad.com/story_parts/31040628/images/13cd9506982ebf05.jpg"> <span>Title</span> </div>
    <div class="block"><img src="https://d.wattpad.com/story_parts/31040628/images/13cd9506982ebf05.jpg"> <span>Title</span> </div>
    <div class="block"><img src="https://d.wattpad.com/story_parts/31040628/images/13cd9506982ebf05.jpg"> <span>Title</span> </div>
    <div class="block"><img src="https://d.wattpad.com/story_parts/31040628/images/13cd9506982ebf05.jpg"> <span>Title</span> </div>
    <div class="block"><img src="https://d.wattpad.com/story_parts/31040628/images/13cd9506982ebf05.jpg"> <span>Title</span> </div>
    <div class="block"><img src="https://d.wattpad.com/story_parts/31040628/images/13cd9506982ebf05.jpg"> <span>Title</span> </div>
    <div class="block"><img src="https://d.wattpad.com/story_parts/31040628/images/13cd9506982ebf05.jpg"> <span>Title</span> </div>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Daniil Kolesnichenko, 2016-03-30
@KolesnichenkoDS

Alternatively:
1. Place the cursor at the beginning of the first opening tag <span>
2. Press Ctrl+V
3. Select the block with all tags <span>(including closing tags)
4. Press d
5. Move the cursor to the beginning of the first tag <img>
6. Press Ctrl+V
7. Press jas many times as needed, so that the cursor is at the beginning of the last tag 8. <img>
Press[p

A
abcd0x00, 2016-03-31
@abcd0x00

You need to record a macro for one line and run it for each line. Ideally, a macro is written in such a way that it starts actions at the beginning of a line, and ends actions at the beginning of the next line (so that you can simply run it and it converts lines sequentially one after another).
Vim has a macro recorder and Emacs has a macro recorder.
How to make the macro itself:
1. You need to put the cursor at the beginning of the line.
2. Enable macro recording.
3. Search for the string to find the beginning of the " <img" tag.
4. Return to the opening angle bracket.
5. Start selection.
6. Through the search, go to the closing angle bracket.
7. Go beyond the closing angle bracket.
8. Cut selection.
9. Through the search, find the end of the " span>" tag.
10. Go beyond the closing angle bracket.
11. Paste the contents of the clipboard.
12. Go to the end of the line.
13. Go to the next line.
14. Return to the beginning of the line.
15. Stop macro recording.
So much has been written here, not because there is much to do, but to make everything clear. Actually, it takes 10 seconds.
The faster you get used to macros, when you write down several of them a day, the faster you will process such texts. This is a very powerful tool.
In Vim, macros are weaker than in Emacs, you can save them less there, and, it seems, there is no powerful editor, while in Emacs there are several modes for editing macros, they can be written in symbolic form as plain text (not only write down actions), and you can simply partially change them and debug them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question