2

Consider the following text file.

line1f line1n
line2

Suppose I visual select this, yank it into register a, and then pass it to the following vimscript function:

function TestSplit(block)
 for x in split(a:block, "\0")
    echom x
    echom "hi"
 endfor
 return 0
endfunction

The output will be

line1f
hi
line1n
hi
line2
hi

What can I replace \0 with to get the following output?

line1f line1n
hi
line2
hi

That is, I want to split on a logical newline for Vim. Note that I also tried \r and got this output.

line1f line1n^@line2
hi
1
  • 5
    use "\n" as split character (in double quotes) Commented May 25, 2019 at 8:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.