I'm trying to write a function to write the contents of the current paragraph the cursor is on to a temp file. In normal more vip:w!temp.txt<cr> works fine, but placing normal! vip:w!unidecode.txt<cr> within a function doesn't seem to.

Any ideas on a clean way to do this?

2 Answers 2


The "clean" way is to avoid normal if possible. So simply

'{,'}write foobar
  • Thank's so much. This is exactly it. Much appreciated!
    – toomey8
    Commented May 7, 2022 at 15:43

Just to give the alternative:

:normal! vip:write file

Should work (there should be an implicit finish for the : I believe). If not, alternatives are

:execute "normal! vip:write file\<cr>"


:normal! vip
:'<,'>write file

You can see why avoiding normal mode commands in Ex is simpler :)

Your Answer

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

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