Jürgen Krämer wrote:
Mark Woodward wrote:
came across this [Emacs] link the other day and wondered if Vim
can do this?
http://steve-yegge.blogspot.com/
[snip]
1. change these to number order starting at 1 (1, 2, 3, 4 etc)
2. change these to alpha list (a, b, c, etc)
[This one has me stumped although I'm sure I've seen something
along these lines before. ? something to do with sub-replace-special
and submatch?]
1987:Bogotá
5243:Fabergé
9772:Mallarmé
12044:Paraná
12499:Poincaré
<snip>
any hints?,
1.) if this text starts at line 1
%s/^\d\+:/\=line('.') . '.) '/
2.) for at most 26 lines
%s/^\d\+:/\=nr2char(char2nr('a') + line('.') - 1) . ') '/
I've never spent much time learning the syntax for this
sort of thing, and I'm very curious about the motivation
for it. For example, for these 2 cases, I would simply
filter the text through sort (ie, to get the
list sorted alphabetically, assuming the entire
file was the list and the cursor was on the
first line, I'd do: !Gsort -t ':' -k 2)
I suppose if I were working in an environment
that didn't have good external filters, I'd need to
learn to do this sort of text manipulation directly
from the editor, but I'm not sure I really grok the
point. Is it primarily to cover the situation where
external filters aren't available?