每行增加行号
-
- 帖子: 980
- 注册时间: 2008-04-12 12:44
每行增加行号
对一个文本的每行开头增加一个行号
:%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
- lilydjwg
- 论坛版主
- 帖子: 4250
- 注册时间: 2009-04-11 23:46
- 系统: Arch Linux
- 联系:
Re: 每行增加行号
说得很清楚了,代表当前行啊。
- yjcong
- 帖子: 2470
- 注册时间: 2006-02-28 3:11
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
-
- 帖子: 433
- 注册时间: 2009-07-06 14:26
- oneleaf
- 论坛管理员
- 帖子: 10441
- 注册时间: 2005-03-27 0:06
- 系统: Ubuntu 12.04
Re: 每行增加行号
eexpress 写了:擦,居然还有nl
- 枫叶饭团
- 帖子: 14683
- 注册时间: 2010-06-16 1:05
- 系统: Mac OS X
- 来自: Tencent
- 联系:
- tpli
- 帖子: 250
- 注册时间: 2007-01-16 16:14
- 来自: 郑州
Re: 每行增加行号
nl貌似不行的..
xhm@xhmdeb:~$ cat usecontext
/home/xhm/context/tex/setuptex
export OSFONTDIR=/home/xhm/font/context
mtxrun --script fonts --reload
xhm@xhmdeb:~$
xhm@xhmdeb:~$ nl usecontext > nlout
xhm@xhmdeb:~$ cat nlout
1 /home/xhm/context/tex/setuptex
2 export OSFONTDIR=/home/xhm/font/context
3 mtxrun --script fonts --reload
xhm@xhmdeb:~$
- oneleaf
- 论坛管理员
- 帖子: 10441
- 注册时间: 2005-03-27 0:06
- 系统: Ubuntu 12.04
Re: 每行增加行号
代码: 全选
nl -ba usecontext
-
- 帖子: 980
- 注册时间: 2008-04-12 12:44
Re: 每行增加行号
. the cursor position,光标的位置,那么" " ,这里的引号是什么意思呢?
- tpli
- 帖子: 250
- 注册时间: 2007-01-16 16:14
- 来自: 郑州
Re: 每行增加行号
thx,oneleaf 写了:代码: 全选
nl -ba usecontext
忘记man了...