Difference between revisions of "Vim"

From Free Knowledge Base- The DUCK Project: information for everyone
Jump to: navigation, search
m
m (some other local vim references)
 
(2 intermediate revisions by one user not shown)
Line 7: Line 7:
 
Using vi is easy to learn, using vim is even easier.  Open the editor, then press the i key to put you into INSERT MODE and start typing.  [esc] takes you out of insert mode.  pressing the SHIFT + : key (shift colon) and w to save or q to quit.  Press SHIFT + : then the h key ENTER for help on all commands.
 
Using vi is easy to learn, using vim is even easier.  Open the editor, then press the i key to put you into INSERT MODE and start typing.  [esc] takes you out of insert mode.  pressing the SHIFT + : key (shift colon) and w to save or q to quit.  Press SHIFT + : then the h key ENTER for help on all commands.
  
Guides such as the good ol "Best of VIM Tips by David Rayner" will get you started using the editor quickly.  See the guide on our [[Vim Tips]] page along with other wiki user contributions.
+
Guides such as the good ol "[[Vim Tips|Best of VIM Tips by David Rayner]]" will get you started using the editor quickly.  See the guide on our [[Vim Tips]] page along with other wiki user contributions.
  
 
== .vimrc ==
 
== .vimrc ==
Line 42: Line 42:
 
  set nowrap
 
  set nowrap
 
  let loaded_matchparen = 1
 
  let loaded_matchparen = 1
 +
 +
The above example was taken from "'''Disable automatic comment insertion'''" on the [[Vim Tips]] page.
  
 
== plugins ==
 
== plugins ==
Line 50: Line 52:
 
* [[Regular Expressions Tutorial]]
 
* [[Regular Expressions Tutorial]]
 
* [[Linux Console Text Editors]]
 
* [[Linux Console Text Editors]]
 +
* [[Vi Short Command Reference]]

Latest revision as of 05:40, 9 August 2020

vim - Vi IMproved, a programmers text editor

Vim is a hyperefficient text editor and provides an extensive plug-in system which can be configured to user preferences. It also supports hundreds of programming languages and file extensions.

Using vim

Using vi is easy to learn, using vim is even easier. Open the editor, then press the i key to put you into INSERT MODE and start typing. [esc] takes you out of insert mode. pressing the SHIFT + : key (shift colon) and w to save or q to quit. Press SHIFT + : then the h key ENTER for help on all commands.

Guides such as the good ol "Best of VIM Tips by David Rayner" will get you started using the editor quickly. See the guide on our Vim Tips page along with other wiki user contributions.

.vimrc

A default Vim installation will feature a file containing Vim’s core global settings called vimrc. This file will be located at either /etc/vim/vimrc or etc/vimrc, depending on your linux distribution.

A file that contains initialization commands is called a "vimrc" file. Each line in a vimrc file is executed as an Ex command line. It is sometimes also referred to as "exrc" file. They are the same type of file, but "exrc" is what Vi always used, "vimrc" is a Vim specific name. Also see |vimrc-intro|.

Places for your personal initializations:

Unix            $HOME/.vimrc or $HOME/.vim/vimrc
OS/2            $HOME/.vimrc, $HOME/vimfiles/vimrc
                or $VIM/.vimrc (or _vimrc)
MS-Windows      $HOME/_vimrc, $HOME/vimfiles/vimrc
                or $VIM/_vimrc
Amiga           s:.vimrc, home:.vimrc, home:vimfiles:vimrc
                or $VIM/.vimrc

The files are searched in the order specified above and only the first one that is found is read.

RECOMMENDATION: Put all your Vim configuration stuff in the $HOME/.vim/ directory ($HOME/vimfiles/ for MS-Windows). That makes it easy to copy it to another system.

If Vim was started with "-u filename", the file "filename" is used. All following initializations until 4. are skipped. $MYVIMRC is not set.

"vim -u NORC" can be used to skip these initializations without reading a file. "vim -u NONE" also skips loading plugins. |-u|

If Vim was started in Ex mode with the "-s" argument, all following initializations until 4. are skipped. Only the "-u" option is interpreted.

To disable an annoying behavior, such as bracket matching, you type :NoMatchParen while in the editor. You cannot add that syntax to .vimrc because the behavior is from a plugin called "matchparen.vim". To disable the behavior you can remove the plugin, or disable the plugin from loading by typing the following in .vimrc

let loaded_matchparen = 1

Here is an example .vimrc file located in /home/<username>/.vimrc

set ignorecase
set nowrap
let loaded_matchparen = 1

The above example was taken from "Disable automatic comment insertion" on the Vim Tips page.

plugins

some other local vim references