Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试定义一个函数,A如果有偶数个美元符号(在我的缓冲区中),并且B如果有奇数个美元符号。但是,我不确定如何计算美元符号的数量,然后报告该数字以定义函数。例如,输入
A
B
:%s/\$//gn
会在状态行吐出这个数字。但是如何将结果应用于定义函数呢?
根据@DaveNewman 的评论,您可以写:
:%s/\$//gn | let i = split(v:statusmsg)[0] | if i % 2 | ... | else | ... | endif