close file from vim terminal code example Example 1: vi save and exit //Save :w //Exit :q Example 2: close vim wq – Save the file and exit Vim