I'm trying to define a function that does A
if there's an even number of dollar signs (in my buffer), and B
if there's an odd number of dollar signs. However, I'm unsure how to count the number of dollar signs, and then report that number for defining the function. For instance, entering
:%s/\\$//gn
will spit out this number on the status line. But how can one apply the result for defining a function?
根据@ DaveNewman的评论,你可以写:
:%s/\$//gn | let i = split(v:statusmsg)[0] | if i % 2 | ... | else | ... | endif
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.