How to exit vim

The Vim text editor tool was mostly developed by Bram Moolenaar, in addition to a subset of other smart & dedicated individuals. It can be used to edit plain text of all kinds. In contrast to what most people belive there is another way of exiting vim instead of just opting to reboot the comuter. Additionally, Vim has “on-line” help which can be accessed by entering “:help”.

In this article you will find a really basic introduction to vim. The general syntax to make use of vim is: user@pc:~$ vim [options] [filelist]. For the Arabic reading experience, please try: user@pc~:$ vim -A [file]. There is a lot of commands that can be utilized and I believe, in trained hands it is a tool of great power, however for this post I am sticking to the fundamentals, aiming to make it to the other side:

  1. Enter vim
  2. Do stuff in vim
  3. Exit vim.

1. Enter vim

2. Do stuff in vim

2.1 Enable Creature Comforts

The following configuration will allow for a better user experience whilst using vim. It should be noted that these configuration changes will not persist when vim is closed. Therefore, if you plan on using vim again you should save it to: ~/.vimrc

2.1.1 Note the line numbers on the left hand side are now enabled.
2.1.2 Enables you to scroll with your mouse scroll wheel/touchpad, in addition to the line.

2.2 Search

Using /{keyword} will allow you to search for a pattern

2.3 Insert Text

Once again there are a few options with each ideal for different situations, but pressing i will work just fine to allow for text editing. After inserting a value you can exit insert mode using the escape character on your keyboard.

2.4 Copy and Paste

This part can be tricky, to copy first ensure that your cursor I is 300|1 one character left from where you want to copy . After that you need to press v to enter visual mode. Being in visual mode you should now be able to highlight text using the arrow keys, pressing y to copy it.
To paste ensure your cursor is where you want to paste eg 8|0:3001. After that just press p. To clean up press i to remove the 80 text.

3. Exit vim

There are a few different methods to exit vim, taking it that the changes are correct and wanted write quit :wq is the way to go. Your options to exit:

  • :w – write/save but do not exit yet.
  • :wq write and quit
  • : x write and quit (if I do not add a space it turns it an emoji 😡 )
  • :q quit altough does not work with unsaved work.
  • :q! quit and discard any unsaved work.

Vim cheat sheet: https://gist.github.com/nerdalert/5f80853b4e195204bc6d

Vim pro explaining Vim for an hour: https://youtu.be/RZ4p-saaQkc?si=fo8KVeymaVMpVDFx

A random link has just shown up and it refuses to be removed: https://nano-editor.org/download.php


Posted

in

,

by

Tags: