Difference between revisions of "Vim"
m |
m |
||
Line 1: | Line 1: | ||
− | |||
− | |||
== General == | == General == | ||
− | Vim 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 graphical user interface. An alternative to using a shell-based editor over [[ssh]] is to transfer the file in question via [[scp]], [[ftp]] (or [[Getting_Started#File_Transfer_or_How-to-get-your-data-onto-or-off-the-supercomputer|File-Transfer]] in general) then use an editor or IDE with a graphical user interface (like Notepad++, VSCode, or whatever you fancy) locally and after that transfer the file back to the remote (super)computer again. As this can be a lot of effort, just to fix a missing ; or typo, vim can come in handy. | + | 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 graphical user interface. An alternative to using a shell-based editor over [[ssh]] is to transfer the file in question via [[scp]], [[ftp]] (or [[Getting_Started#File_Transfer_or_How-to-get-your-data-onto-or-off-the-supercomputer|File-Transfer]] in general) then use an editor or IDE with a graphical user interface (like Notepad++, VSCode, or whatever you fancy) locally and after that transfer the file back to the remote (super)computer again. As this can be a lot of effort, just to fix a missing ; or typo, vi/vim can come in handy. |
− | 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|References]] or the internet in general. There are lots of good resources out there covering | + | 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|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 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|References]] or the internet. | + | 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|References]] or the internet. |
Line 17: | Line 15: | ||
{| class="wikitable" style="width: 40%;" | {| class="wikitable" style="width: 40%;" | ||
− | | :q || to quit | + | | :q || to quit Vi/Vim |
|- | |- | ||
| :w || to save the current file | | :w || to save the current file | ||
|- | |- | ||
− | | :q! || to quit | + | | :q! || to quit Vi/Vim without saving (discarding changes) |
|- | |- | ||
− | | :x || to quit | + | | :x || to quit Vi/Vim with saving changes |
|} | |} | ||
Line 36: | Line 34: | ||
[https://wiki.gentoo.org/wiki/Vim/Guide Vim/Guide in the Gentoo wiki] | [https://wiki.gentoo.org/wiki/Vim/Guide Vim/Guide in the Gentoo wiki] | ||
+ | |||
+ | [http://www.viemu.com/a-why-vi-vim.html Why should you use vi (or vim)] | ||
[https://vim-adventures.com/ Vim Game] | [https://vim-adventures.com/ Vim Game] |
Revision as of 14:39, 28 February 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 graphical user interface. An alternative to using a shell-based editor over ssh is to transfer the file in question via scp, ftp (or File-Transfer in general) then use an editor or IDE with a graphical user interface (like Notepad++, VSCode, or whatever you fancy) locally and after that transfer the file back to the remote (super)computer again. As this can be a lot of effort, just to fix a missing ; or typo, vi/vim can come in handy.
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.
Save/quit/help
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.