Zam
Zam

Reputation: 377

How to add line break in vim script

I am a beginner in vim.

The following code is just a piece of code that i have. How to add line break between "just" and "an".

call append(line('.') - 1, 'This' .'is' .'just' . "\r" . 'an' . selected_content . 'example')

This code is not working. and got junk like (^M)

Upvotes: 0

Views: 967

Answers (1)

Luc Hermitte
Luc Hermitte

Reputation: 32966

Split your string into a |List|, and then, it'll work.

call append('.', ['This' .'is' .'just',  'an' . selected_content . 'example'])

If as I suspect the string is built, then is won't be difficult to use a list instead of a string in your code. Otherwise, you'll need to use split(line, "\n")

Upvotes: 2

Related Questions