Difference between revisions of "Vim"

From Apertium
Jump to navigation Jump to search
Line 1: Line 1:
Vim is a text editor.
+
Vim is a powerful modal text editor. It is a very capable tool, but may be overwhelming.
  +
A tutorial built in to the editor can be opened by running <code>vimtutor</code> from a terminal.
  +
<code>vimtutor</code> is a great introduction to it, and is enough to get you started.
   
  +
==Absolute Basics==
It edits text.
 
  +
Vim starts in 'normal mode', and in order to type any text, you must first switch to 'insert mode'.
 
  +
This can be done by pressing <code>i</code>. In 'insert mode', vim behaves like most other text editors and will allow you to type text into the buffer.
It is a "modal" editor, meaning that you can switch "modes."
 
  +
You can leave 'insert mode' and go to 'normal mode' by pressing the <code>Esc</code> key. Here, pressing keys executes commands on the text instead of typing them, for example <code>w</code> to move the cursor forward by a word.
Vim starts in Command mode. More on this below.
 
By pressing 'i', you can switch to Insert mode. In Insert mode, you just move around with the arrow keys or mouse like in a normal editor. To type, well, just type. To get back to Command mode, press Esc.
 
 
==Command mode==
 
Vim has literally hundreds of different commands. However, you don't need to be overwhelmed. Just know the following, and you'll be fine for starting out.
 
   
  +
Some essential commands:
 
* <code>ZZ</code> - save and exit
 
* <code>ZZ</code> - save and exit
 
* <code>:open <file></code> - open <file>
 
* <code>:open <file></code> - open <file>
Line 17: Line 16:
 
* <code>:%s/<find>/<replace>/g</code> - find <find> and replace it with <replace>
 
* <code>:%s/<find>/<replace>/g</code> - find <find> and replace it with <replace>
 
* <code>i</code> - switch to Insert mode
 
* <code>i</code> - switch to Insert mode
  +
*<code>:h <topic></code> - opens the built-in documentation for a given <topic>
  +
  +
https://danielmiessler.com/study/vim/ is a good article for those interesting in learning the more advanced and powerful features of vim.
   
 
==Editing XML (dix, transfer rules) in vim==
 
==Editing XML (dix, transfer rules) in vim==

Revision as of 14:41, 29 December 2020

Vim is a powerful modal text editor. It is a very capable tool, but may be overwhelming. A tutorial built in to the editor can be opened by running vimtutor from a terminal. vimtutor is a great introduction to it, and is enough to get you started.

Absolute Basics

Vim starts in 'normal mode', and in order to type any text, you must first switch to 'insert mode'. This can be done by pressing i. In 'insert mode', vim behaves like most other text editors and will allow you to type text into the buffer. You can leave 'insert mode' and go to 'normal mode' by pressing the Esc key. Here, pressing keys executes commands on the text instead of typing them, for example w to move the cursor forward by a word.

Some essential commands:

  • ZZ - save and exit
  • :open <file> - open <file>
  • :qa! - discard all changes and exit
  • :w - save changes but do not exit
  • :w <file> - save as <file> (note that this must be followed by :open <file> if future :ws should use <file>)
  • :%s/<find>/<replace>/g - find <find> and replace it with <replace>
  • i - switch to Insert mode
  • :h <topic> - opens the built-in documentation for a given <topic>

https://danielmiessler.com/study/vim/ is a good article for those interesting in learning the more advanced and powerful features of vim.

Editing XML (dix, transfer rules) in vim

http://www.pinkjuice.com/howto/vimxml/ is a nice guide to editing XML in vim.

Editing Xerox formats in vim

Various people have created lexc/twol syntax files for vim:

See also Apertium-specific conventions for lexc#Syntax highlighting and folding in vim