Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any Tutorial on how to create a Vim-like editor? [closed]

I've been an avid Vim user, and recently became interested in how it works.

Does anyone know if there's a tutorial that goes over basics of converting a normal text editor to have Vi/m capability? The programming language does not matter; I'm quite an experienced programmer.

I have found the following resources so far:

  • The Craft of Text Editing
  • Implementation of Vi Editor with NCURSES
  • Vi Editor implemented in Python
  • Ruvi: Vi(m) clone in Ruby
like image 721
sivabudh Avatar asked Jun 05 '12 18:06

sivabudh


People also ask

How do you close and write in Vim?

TL;DR – How to Exit Vim If you made some changes and would like to keep them, type :wq and press Enter / return. If you made some changes and would rather discard them, type :q! and press Enter / return.

Which command is used to close the Vim editor?

Exit Vim Using a Shortcut Key In addition to command mode, Vim also has the option for shortcut keys: To save a file in Vim and exit, press Esc > Shift + ZZ. To exit Vim without saving, press Esc > Shift + ZX.


1 Answers

I think first you should know that VI/VIM are actually two parts. One is the visual editor called vi and the other on is the one-liner editor called ed.

Actually vi is called visual editor because it's built on top of ed(editor). It is the visual part of the ex mode, where you can see and edit your text, that's why it get the name vi from visual.

The ex mode is actually a replication/representation of the editor ed. Just fire up ed on the terminal and use your default Vi ex commands. The visual, replace and insert modes are used by vi. For example there are several commands that are actually doing the same thing, for example:

:100 // Go to line 100, ex mode (ed)
100G // Go to line 100, normal mode(vi)

:.,5d // Delete 5 lines, ex mode (ed)
5dd   // Delete 5 lines, normal mode (vi)

and so on...

For more information on that I recommended to read the excellent book Learning the vi and Vim editors from O'Reilly:

alt text

like image 74
Fatih Arslan Avatar answered Oct 02 '22 22:10

Fatih Arslan