每行增加行号
发表于 : 2013-05-26 15:36
对一个文本的每行开头增加一个行号
:%s/^/\=line(".")/
% 代表所有行
s 代表替换
^ 行头
请问 这个 \= 里面的 \ 符号,是表达转义的含义吗?
line函数里面的 (".") "." 是什么含义?看了帮助手册也没有懂。
line({expr}) The result is a Number, which is the line number of the file
position given with {expr}. The accepted positions are:
. the cursor position
$ the last line in the current buffer
'x position of mark x (if the mark is not set, 0 is
returned)
w0 first line visible in current window
w$ last line visible in current window
v In Visual mode: the start of the Visual area (the
cursor is the end). When not in Visual mode
returns the cursor position. Differs from |'<| in
that it's updated right away.
Note that a mark in another file can be used. The line number
:%s/^/\=line(".")/
% 代表所有行
s 代表替换
^ 行头
请问 这个 \= 里面的 \ 符号,是表达转义的含义吗?
line函数里面的 (".") "." 是什么含义?看了帮助手册也没有懂。
line({expr}) The result is a Number, which is the line number of the file
position given with {expr}. The accepted positions are:
. the cursor position
$ the last line in the current buffer
'x position of mark x (if the mark is not set, 0 is
returned)
w0 first line visible in current window
w$ last line visible in current window
v In Visual mode: the start of the Visual area (the
cursor is the end). When not in Visual mode
returns the cursor position. Differs from |'<| in
that it's updated right away.
Note that a mark in another file can be used. The line number