Created
December 22, 2015 03:20
-
-
Save note103/c8ebd2b311d7a206cb5f to your computer and use it in GitHub Desktop.
行頭に連番を振る
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my @array = <DATA>; | |
my $n = 1; | |
for my $line (@array) { | |
print "$n: $line"; | |
$n++; | |
} | |
__DATA__ | |
apple | |
orange | |
lemon | |
grape |
:put=range(1,5)
とVimのコマンドラインで実行すると、
1
2
3
4
5
という5行が挿入されます。それらを矩形選択でコピーしておいて、
This is a pen
this is a pen
this is a pen
this is a pen
this is a pen
↑の1行目、大文字T
のところにカーソルをあてた状態で P
で貼り付けると、
1This is a pen
2this is a pen
3this is a pen
4this is a pen
5this is a pen
という具合で、冒頭に連番が振れました。矩形選択コピーしたものを P
で行頭に貼り付け、ちょいちょい使ってます。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
1: apple
2: orange
3: lemon
4: grape