Vim

From Apertium
Jump to navigation Jump to search

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.

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

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