Fixes #1783

This commit fixes #1783 and adds tests to vim_tests.js to exercise the added functionality.