Skip to content

Instantly share code, notes, and snippets.

@note103
Created December 22, 2015 03:20
Show Gist options
  • Save note103/c8ebd2b311d7a206cb5f to your computer and use it in GitHub Desktop.
Save note103/c8ebd2b311d7a206cb5f to your computer and use it in GitHub Desktop.
行頭に連番を振る
my @array = <DATA>;
my $n = 1;
for my $line (@array) {
print "$n: $line";
$n++;
}
__DATA__
apple
orange
lemon
grape
@note103
Copy link
Author

note103 commented Dec 22, 2015

1: apple
2: orange
3: lemon
4: grape

@harupong
Copy link

: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