Difference between revisions of "Vim"

From Apertium
Jump to navigation Jump to search
m
 
(4 intermediate revisions by 4 users not shown)
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.
  +
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.
  +
  +
Some essential commands:
  +
* <code>ZZ</code> - save and exit
  +
* <code>:open <file></code> - open <file>
  +
* <code>:qa!</code> - discard all changes and exit
  +
* <code>:w</code> - save changes but do not exit
  +
* <code>:w <file></code> - save as <file> (note that this must be followed by <code>:open <file></code> if future <code>:w</code>s should use <file>)
  +
* <code>:%s/<find>/<replace>/g</code> - find <find> and replace it with <replace>
  +
* <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.
  +
  +
You may want to do <code>:syntax enable</code> as well to enable syntax highlighting.
   
 
==Editing XML (dix, transfer rules) in vim==
 
==Editing XML (dix, transfer rules) in vim==
http://www.pinkjuice.com/howto/vimxml/ is a nice guide to editing XML in vim
+
http://www.pinkjuice.com/howto/vimxml/ is a nice guide to editing XML in vim.
   
 
==Editing Xerox formats in vim==
 
==Editing Xerox formats in vim==
 
Various people have created lexc/twol syntax files for vim:
 
Various people have created lexc/twol syntax files for vim:
 
* https://github.com/arnsholt/proiel-morphology/tree/master/vim
 
* https://github.com/arnsholt/proiel-morphology/tree/master/vim
* https://github.com/flammie/dotfiles/tree/master/vim/syntax
+
* https://github.com/flammie/vim-finitestatemorphology (works with vundle as flammie/vim-finitestatemorphology)
 
* https://github.com/jonorthwash/dotfiles/tree/master/vim
 
* https://github.com/jonorthwash/dotfiles/tree/master/vim
   
  +
See also [[Apertium-specific conventions for lexc#Syntax highlighting and folding in vim]]
See also http://wiki.apertium.org/wiki/Apertium-specific_conventions_for_lexc#Syntax_highlighting_in_vim
 
   
 
[[Category:Documentation in English]]
 
[[Category:Documentation in English]]

Latest revision as of 16:00, 2 January 2021

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[edit]

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.

You may want to do :syntax enable as well to enable syntax highlighting.

Editing XML (dix, transfer rules) in vim[edit]

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

Editing Xerox formats in vim[edit]

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

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