how to save and exit a file in vim code example Example 1: vi save and exit //Save :w //Exit :q Example 2: save and close vim // Save & exit(quit) :wq