Difference between revisions of "Vim"

From HPC Wiki
Jump to navigation Jump to search
Line 3: Line 3:
 
Vi or Vim (VI IMproved) is a visual text editor that can be run inside a [[shell]]. This has the advantage, that you can quickly write or edit text files in the [[shell]], even over an [[ssh]] connection without needing a graphical user interface. Alternatively there is the option to edit the file(s) locally (on your desktop computer) in your favourite editor or IDE (e.g. Notepad++, VSCode, ...) and then transfer the files to the remote (super)computer. Visit the [[File_Transfer|file transfer]] page for more information on that topic. As these tansfers can be a lot of effort, just to fix a missing <code>;</code> or typo, Vi/Vim can come in handy, as they are available on practically every Unix system.
 
Vi or Vim (VI IMproved) is a visual text editor that can be run inside a [[shell]]. This has the advantage, that you can quickly write or edit text files in the [[shell]], even over an [[ssh]] connection without needing a graphical user interface. Alternatively there is the option to edit the file(s) locally (on your desktop computer) in your favourite editor or IDE (e.g. Notepad++, VSCode, ...) and then transfer the files to the remote (super)computer. Visit the [[File_Transfer|file transfer]] page for more information on that topic. As these tansfers can be a lot of effort, just to fix a missing <code>;</code> or typo, Vi/Vim can come in handy, as they are available on practically every Unix system.
  
While it's usage is far from intuitive, a few basics are generally helpful. For a more complete coverage of this editor, why people use it and why you should probably do that too, please look at the [[Absolute_Basics|vimtutor]], the [[#References|References]] or the internet in general. There are lots of good resources out there covering Vi/Vim and why/how-to use it.
+
While it's usage is far from intuitive, a few basics are generally helpful. For a more complete coverage of this editor, why people use it and why you should probably do that too, please look at the [[#Absolute_Basics|vimtutor]], the [[#References|References]] or the internet in general. There are lots of good resources out there covering Vi/Vim and why/how-to use it.
  
 
== Modes ==
 
== Modes ==

Revision as of 12:53, 10 April 2018

General

Vi or Vim (VI IMproved) is a visual text editor that can be run inside a shell. This has the advantage, that you can quickly write or edit text files in the shell, even over an ssh connection without needing a graphical user interface. Alternatively there is the option to edit the file(s) locally (on your desktop computer) in your favourite editor or IDE (e.g. Notepad++, VSCode, ...) and then transfer the files to the remote (super)computer. Visit the file transfer page for more information on that topic. As these tansfers can be a lot of effort, just to fix a missing ; or typo, Vi/Vim can come in handy, as they are available on practically every Unix system.

While it's usage is far from intuitive, a few basics are generally helpful. For a more complete coverage of this editor, why people use it and why you should probably do that too, please look at the vimtutor, the References or the internet in general. There are lots of good resources out there covering Vi/Vim and why/how-to use it.

Modes

In Vi/Vim there are two modes. Normal mode and Insert mode. You switch to normal mode with the 'ESC' key and into insert mode by pressing 'i'. Insert mode works more or less like you would expect a normal text editor to work with arrow keys, backspace and typing deleting/producing characters. More information about what normal mode is good for etc. can be found in the References or the internet.


Absolute Basics

To call Vi(m) on yourfile.txt simply enter

$ vi yourfile.txt                                         $ vim yourfile.txt


From normal mode (press Esc to get there) you can type


:q to quit Vi/Vim
:w to save the current file
:q! to quit Vi/Vim without saving (discarding changes)
:x to quit Vi/Vim with saving changes

For a tutorial you can call the

$ vimtutor

and follow the instructions on screen.


References

Interactive Vim Tutorial

Vim/Guide in the Gentoo wiki

Why should you use vi (or vim)

Vim Game