Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • Hello, thanks. The former solution doesn't work for some reason; Command Prompt gives me an error 'ex' is not recognized as an internal or external command, operable program or batch file.. The second version doesn't really swap characters; bar.txt contains only a. Commented Sep 5, 2020 at 14:49
  • 2
    The first assumes you have ex (comes with vim, maybe not with gvim?). As for the second, I find that odd.. it could be a cursor issue? You might want 1 then normal! 0xp or some other sequence to position the cursor appropriately. Commented Sep 5, 2020 at 15:25
  • 2
    ex is required on posix systems; again, not sure about the windows install of vim. The issue with a non-default vimrc is likely some autocommand restoring a file position or some other thing. You can use -u and other options to force the default vimrc, none, or some other combination. @johnc.j. Commented Sep 5, 2020 at 15:56
  • 2
    If Ex is not found, you can try to substitute ex by vim -e. In GNU/Linux systems, Ex is just Vim in Ex mode. Also, there are other tools to do this job, for example, Sed. Commented Sep 5, 2020 at 16:52
  • 2
    @Quasímodo agreed; this is one of those cases where sed really is right (i.e., we're not trying to edit in place with a stream editor 🙄—excuse the rant) Commented Sep 5, 2020 at 16:57