1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.