0

Why does replacement of something by using :%s/,/\n/gc in vim gives me ^@ instead of giving me newline. Sed replacement works perfectly sed s/,/'\n'/g. Any idea how to do sed thingy in Vim and save time.

2
1

Simply because a line break in the replacement component of the substitution command is represented by \r in Vim rather than \n...

:s/,/\r/gc

Alernatively, you can use this:

:s/,/^M/gc

Where the ^M is entered by typing Ctrl+V then Enter

See :h s/\r and :h s/<CR>

FYI using \n will...

insert a <NL> (<NUL> in the file) (does NOT break the line)

...to quote :h s/\n

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.