exit vim in javascript

Exiting Vim can be a bit tricky for new users, especially if they are not familiar with its command mode. In order to exit Vim in JavaScript, follow these steps:

  1. Press the Esc key to enter command mode
  2. Type :q! to force quit without saving changes
  3. Press Enter to execute this command and exit Vim

Alternatively, if you have made changes and want to save them before exiting, follow these steps instead:

  1. Press Esc key to enter command mode
  2. Type :wq to write changes and quit
  3. Press Enter to execute this command and exit Vim

Here's an example of how to do it:

index.tsx
// Entering command mode
pressKey('Esc');

// Force quit without saving changes
type(':q!');

// Execute the command by pressing Enter
pressKey('Enter');
154 chars
9 lines
index.tsx
// Entering command mode
pressKey('Esc');

// Write changes and quit
type(':wq');

// Execute the command by pressing Enter
pressKey('Enter');
143 chars
9 lines

gistlibby LogSnag