Difference between revisions of "Vi editor"

From Teknologisk videncenter
Jump to: navigation, search
m (VIM and FreeBSD malfunctioning arrow keys in insert mode)
m
Line 28: Line 28:
 
== VIM and FreeBSD malfunctioning arrow keys in insert mode ==
 
== VIM and FreeBSD malfunctioning arrow keys in insert mode ==
 
Set ''vim'' to work in ''nocompatible'' mode. Not as old ''vi''.
 
Set ''vim'' to work in ''nocompatible'' mode. Not as old ''vi''.
<source lang="cli">
+
<pre class="pre">
 
[root@mars ~]# <input>echo "set nocompatible" >> $HOME/.vimrc</input>
 
[root@mars ~]# <input>echo "set nocompatible" >> $HOME/.vimrc</input>
</source>
+
</pre>
 
== Inserting control characters in documents ==
 
== Inserting control characters in documents ==
 
Using the <CTRL>-v and a inserts SOH (001) See [[ASC-II]]. <CTRL>-v and <ESC> inserts <ESC>
 
Using the <CTRL>-v and a inserts SOH (001) See [[ASC-II]]. <CTRL>-v and <ESC> inserts <ESC>
{{#css:
+
 
   
 
    pre {  font-weight: bold; font-size: 150%; color: #00FF00; background: black; margin: 10px 75px;}
 
}}
 
 
[[Category:Operating Systems]][[Category:UNIX]][[Category:Linux]]
 
[[Category:Operating Systems]][[Category:UNIX]][[Category:Linux]]

Revision as of 11:44, 21 August 2009

FAQ

Syntax highlighting

To use syntax highlighting temporarily use the command :syntax on. To switch it off again use :syntax off.

To use syntax highlighting permanently use

[root@mars ~]# <input>echo "syntax on" >> $HOME/.vimrc</input>

Line numbers in vi

To use line numbers temporarily use the command :set number. To switch it off again use :set nonumber.

To use line number permanently use

[root@mars ~]# <input>echo "set number" >> $HOME/.vimrc</input>

Which editor mode are I'm in

Use showmode option. Shown below

[root@mars ~]# <input>echo "set showmode" >> $HOME/.vimrc</input>

Now you can see which mode you are in by looking at the bottom line

  1. In insert mode it will write -- INSERT --
  2. In replace mode it will write -- REPLACE --
  3. In line command mode it will write a colon (:) in the lower left cornor of the screen.
  4. In command mode - empty or everything else

VIM and FreeBSD malfunctioning arrow keys in insert mode

Set vim to work in nocompatible mode. Not as old vi.

[root@mars ~]# <input>echo "set nocompatible" >> $HOME/.vimrc</input>

Inserting control characters in documents

Using the <CTRL>-v and a inserts SOH (001) See ASC-II. <CTRL>-v and <ESC> inserts <ESC>