The only workaround I can come up with is after opening a vim session:

:set updatecount=0 | e +setlocal\ noswapfile FILENAME | set updatecount&

Are there any shorter vim commands or options that could achieve the same effect?

  • 1
    make a function, wrap all special needs (set x,set y set z, mapping, au....) for your particular session, when you need it, just call the function by a custom command/mapping
    – Kent
    Jun 28, 2016 at 11:56
  • 2
    Could you go into more detail? Why do you want to disable the swap file and does this involve any particular file type?
    – Tommy A
    Jun 28, 2016 at 12:39

1 Answer 1


You could try :noswapfile e FILENAME:

  :nos[wapfile]   {command}         *:nos* *:noswapfile*
        Execute {command}. If it contains a command that loads a new
        buffer, it will be loaded without creating a swapfile and the
        'swapfile' option will be reset.  If a buffer already had a
        swapfile it is not removed and 'swapfile' is not reset.

But keep in mind that usually there are better solutions, depending on what you are trying to achieve, because without a swap file you are more likely to lose your work.

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.