**In the process of configuring ArchLinux on a PC, I realized just how much more efficiently I work in Vim than I do in any other text editor. So, when Article Day rolled around, I checked to see if there had been an article on Vim. Lo and behold, there was only a brief introduction to Vim. To start with, I should probably differentiate a text editor from an office suite like OpenOffice/LibreOffice. A text editor is used for editing stuff like *.txt, *.rtf, *.conf, *~, and basically any other plain text document format (i.e. no formatting). An office suite, on the other hand, works on *.doc and *.odt files (among others). I usually use plain text documents for quick to-do lists, and for writing code. I'm fairly certain there are many of you out there who either write quick notes to themselves, write code (be it software or websites), and perhaps edit some configuration files. What's the difference between Vim and GVim? Vim is the console-oriented verfsion of the program (for use in gnome-terminal, rxvt-unicode, tty screens, and so forth). GVim is a graphical front-end for Vim, and allows easy access to some of the more esoteric commands. ** C'était lorsque je configurais ArchLinux sur un PC que je me suis rendu compte à quel point je travaille de façon beaucoup plus efficace avec Vim qu'avec aucun autre éditeur de texte. Ainsi, lorsque le Jour de l'article a pointé son nez, j'ai vérifié s'il y avait déjà un article à son sujet. Et voilà qu'il n'y avait qu'une brève présentation de Vim. Pour commencer, je dois sans doute distinguer un éditeur de texte d'une suite bureautique comme OpenOffice/LibreOffice. Un éditeur de texte est utilisé pour éditer des trucs comme *.txt, *.rtf, *.conf, *~ et essentiellement tout autre format de document en texte simple (c-à-d, sans formatage). Quant à une suite bureautique, elle fonctionne notamment avec des fichiers *.doc et *.odt (parmi bien d'autres). Je me sers généralement de documents en texte simple pour créer des listes rapides de choses à faire et pour écrire du code. Je suis quasiment sûr qu'il y en a beaucoup parmi vous qui, soit s'écrivent de notes rapides, soit font du codage (de logiciels ou des sites web) et modifient, peut-être, certains fichiers de configuration. **Why should I use Vim/GVim? I'm not going to say that Vim/GVim is the only text editor anyone should use, but it's the one I prefer. Why do I prefer it? Simply because it offers sane defaults and keybindings that allow for very quick editing - without the need for a mouse. I find that keeping my hands on my keyboard actually allows for faster work than pausing to move the mouse (or keeping a hand on the mouse most of the time). If you find yourself nodding along with this, you should give Vim/GVim a shot. For example: Say you wanted to delete 250 sequential lines in some source code because you need to move the method elsewhere. In Vim you would simply type in 250 and then hit the “d” key twice (for delete line). If you then want to paste it somewhere else, simply move there and hit “p”. No need for a mouse or any highlighting whatsoever. How do you get around if you can't use a mouse? In GVim you are able to use a mouse, though it's really not necessary. In Vim you get around using page up/page down and the arrow keys (or hjkl where h=left, j=down, k=up, and l=right). What about syntax highlighting? Vim and GVim are fully customizable in a configuration file, and allows for custom colors and formatting for code according to file extensions. It also offers a very good syntax engine by default that simply needs to be enabled.** Pourquoi utiliser Vim/GVim ? Je ne vais pas dire que Vim/GVim est le seul éditeur de texte que quiconque devrait utiliser, mais c'est celui que je préfère. Pourquoi ? Tout simplement parce qu'il propose des trucs par défaut de bon sens et des raccourcis claviers qui permettent des modifications très rapides, sans devoir utiliser la souris. Je trouve que je travaille plus vite en gardant les mains sur le clavier au lieu de m'arrêter pour bouger la souris (ou de garder une main sur la souris la plupart du temps). Si vous apercevez que vous êtes en train d'opiner de la tête, vous devriez vraiment essayer Vim/GVim. Par exemple : Disons que vous voulez supprimer 250 lignes séquentielles dans du code source parce qu'il faut mettre la méthode à un autre endroit. Avec Vim, vous taperiez 250, puis frapperiez la touche « d » deux fois (pour supprimer - « delete » - ligne). Si, après vous voulez le coller ailleurs, allez à l'endroit voulu et frappez la touche « p » (pour coller - « paste »). Nul besoin d'une souris ni de mettre quoi que ce soit en surbrillance. Comment s'y déplacer si vous n'utilisez pas de souris ? Dans GVim, l'utilisation de la souris est possible, mais n'est pas vraiment nécessaire. Dans Vim, vous vous déplacez avec Page Préc./ et Page Suiv. et les touches fléchées (ou hjkl, où h= à gauche, j = vers le bas, k = vers le haut et l = à droite). Quid de la coloration syntaxique ? Les deux, Vim et GVim, peuvent être complètement personnalisés dans un fichier de configuration. **What other useful features does it offer? It allows you to: • Set a custom size (number of spaces) for tab characters, which is useful when coding python. • Copy, paste, delete, and insert controls that allow for careful formatting (dw = delete word, dd=delete line, yw=copy word, yy=copy line, p=paste, etc). • Printing (with a sane printing default) • A tutorial that can be accessed with the command 'vimtutor' • Macros (easy creation and execution). Some basic commands: hjkl – movement ( h=left, j=down, k=up, and l=right) – this works only outside of any mode. Inside a mode you'll need to use the arrow keys. y – copy (yy = copy line) d – delete (dd = delete line) w -word (used in conjunction with y or d mainly) 1-∞ - repeat the command that number of times (i.e. 250dd = delete 250 lines starting at, and including, the line currently selected) :w – write (can be combined with q to write and quit)** Quelles autres fonctionnalités utiles propose-t-il ? Il vous permet de : * Personnaliser la taille (le nombre d'espaces) de votre tabulation, ce qui est utile pour coder en python. * Copier, coller, supprimer et insérer des contrôles qui permettent un formatage soigné (dw = supprimer mot), dd = supprimer ligne, yw = copier mot, yy = copier ligne, p = coller, etc.). * Imprimer (avec un défaut de bon sens). * Un tutoriel auquel vous pouvez accéder avec la commande « vimtutor ». * La création et l'exécution faciles de macros. Quelques commandes de base : hjkl - mouvement (h = à gauche, j = vers le bas, k = vers le haut et l = à droite) - cela ne fonctionne qu'en dehors de tout mode. Quand vous travaillez dans un mode quelconque, vous devrez utiliser les touches fléchées. y - copier (yy = copier la ligne) ; d - supprimer (dd = supprimer ligne) ; w - word (mot - utilisé pour la plupart du temps avec y ou d) ; 1-∞ - répéter la commande ce nombre de fois (c-à-d 250dd = supprimer 250 lignes commençant par, et y compris, la ligne actuellement sélectionnée) ; :w - « write » (enregistrer - peut être utilisé avec q pour enregistrer et quitter [Ndt :dans la version 7.2, c'est :wqa qu'il faut utiliser]) ; **:e – open ; :q – quit ; Esc – exit any mode ; i – insert mode (inserts before current selection) ; a – add mode r – replace mode u – undo ctrl+r – redo. p – paste anything copied or deleted in Vim/GVim :hardcopy – the command to print :%s/// - allows you to substitute anything you search for in the first block with what is in the second block. This also accepts regular expressions. :set