分页: 1 / 1

每行增加行号

发表于 : 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

Re: 每行增加行号

发表于 : 2013-05-26 20:24
lilydjwg
说得很清楚了,代表当前行啊。

Re: 每行增加行号

发表于 : 2013-05-26 20:51
yjcong
nl file_input > file_output

??

Re: 每行增加行号

发表于 : 2013-05-26 22:19
eexpress
擦,居然还有nl

Re: 每行增加行号

发表于 : 2013-05-27 9:04
wangjun403
又多了个爱学习的童靴

Re: 每行增加行号

发表于 : 2013-05-27 9:12
oneleaf
eexpress 写了:擦,居然还有nl

Re: 每行增加行号

发表于 : 2013-05-27 9:27
枫叶饭团
nl也是命令?powershell里没有 :em02

Re: 每行增加行号

发表于 : 2013-05-27 9:30
tpli
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:~$

Re: 每行增加行号

发表于 : 2013-05-27 10:13
oneleaf

代码: 全选

nl -ba usecontext

Re: 每行增加行号

发表于 : 2013-05-27 16:47
罗非鱼
. the cursor position,光标的位置,那么" " ,这里的引号是什么意思呢?

Re: 每行增加行号

发表于 : 2013-05-27 17:12
tpli
oneleaf 写了:

代码: 全选

nl -ba usecontext
thx,
忘记man了...