Something that's been bugging me for some time.
I am working on an anthology of French literature and I need to xhtml
this renowned piece from the late 18th century:
| 000 ...
| 001 En tous lieux le cul nous appelle, <br />$
| 002 Le cul met tous les vits en rut,$
| 003 Le cul du bonheur est la voie,$
| 004 Dans le cul gît toute la joie,$
| 005 Mais, hors du cul point de salut.
| 006 ... etc. ^
| col. 60 ____________.
To start off with the cursor is at the beginning of line 001 and I need
to append html linebreaks to lines 002-004. Since I'd rather the source
of the document remain somewhat legible I much prefer having the <br />
tags well-separated from the actual text & neatly aligned in col. 60.
Clarification: the dollar sign at the end of l. 002--004 is NOT part of
the text: lacking a better solution it's only there to represent the
end-of-line: everything beyond in the vim buffer is a NUL character!
To save me some typing (and typos) this is the way I handle it:
1. f< " move cursor to the opening '<'
2. :set virtualedit=all " enable editing beyond end-of-line
3. j " move cursor l. 001 -> l 002
4. CTRL+V " switch to blockwise visual mode
5. 3j " select 1 column × 3 line block
6. I " (upper case) switch to 'block insert'
7. CTRL+Y (6 times) " 'clone' l. 001's <br /> on line 002
8. <ESC> " escape back to normal mode
9. :set virtualedit= " optional - depends on what follows
After hitting <ESC> I'd expect vim to 'magically' clone the '<br />'
already duplicated on l. 002 on lines 003-004. But nothing happens!
I end up with my html linebreak duplicated on l. 002 and nought on l.
003 & 004.
After tinkering with this for a little while I found that if I select
a one-column block on col. 60 (e.g.) including all lines where I need to
add my line breaks and then insert a space there, thus replacing the NUL
character there by a space (but also replacing all NUL characters
-so-to-speak- up to col. 60 by spaces the 1-8 sequence of keystrokes
does what I intend. But that's a LOT of extra work...
Is this to be expected or is it a 'feature'?
Is there a better way (excluding mouse'ing and plugin'ing) to achieve
this?
Thanks,
CJ
PS. As always it takes much longer to describe the editing sequence than
actually performing said sequence. (f<<C-P>j<C-V>3jI<C-Y>×6 + <ESC>) is
all there is to it. With a bit of practice it only takes a couple of
seconds.
PPS. Obviously this approach becomes a lot more useful when dealing with
large chunks of text/verse rather than the 5 lines in the example. It
also comes in handy (very) when editing long tables (in latex e.g.)
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/YOC/jw8VwLynPYqy%40turki.local.
Saturday, July 3, 2021
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment