issue54:c_c
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
issue54:c_c [2011/11/01 17:35] – créée auntiee | issue54:c_c [2011/12/16 17:13] (Version actuelle) – amstram | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | 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/ | + | **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/ |
What's the difference between Vim and GVim? | What's the difference between Vim and GVim? | ||
- | Vim is the console-oriented verfsion of the program (for use in gnome-terminal, | + | Vim is the console-oriented verfsion of the program (for use in gnome-terminal, |
- | Why should I use Vim/GVim? | + | C' |
+ | |||
+ | **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 | 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 | 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 | ||
Ligne 10: | Ligne 12: | ||
How do you get around if you can't use a mouse? | 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? | + | 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? |
- | What other useful features does it offer? | + | 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' | ||
+ | |||
+ | Comment s'y déplacer si vous n' | ||
+ | Dans GVim, l' | ||
+ | |||
+ | **What other useful features does it offer? | ||
It allows you to: | It allows you to: | ||
• Set a custom size (number of spaces) for tab characters, which is useful when coding python. | • Set a custom size (number of spaces) for tab characters, which is useful when coding python. | ||
Ligne 25: | Ligne 33: | ||
w -word (used in conjunction with y or d mainly) | w -word (used in conjunction with y or d mainly) | ||
1-∞< | 1-∞< | ||
- | :w – write (can be combined with q to write and quit) | + | :w – write (can be combined with q to write and quit)** |
- | :e – open | + | |
- | :q – quit | + | Quelles autres fonctionnalités utiles propose-t-il ? |
- | Esc – exit any mode | + | Il vous permet de : |
- | i – insert mode (inserts before current selection) | + | * Personnaliser la taille (le nombre d' |
+ | * 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' | ||
+ | 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-∞< | ||
+ | :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 | a – add mode | ||
r – replace mode | r – replace mode | ||
Ligne 40: | Ligne 64: | ||
I – insert before all highlighted letters | I – insert before all highlighted letters | ||
X – delete all highlighted letters | X – delete all highlighted letters | ||
- | *middle-mouse button (or shift + insert) paste from external linux clipboard after selecting the text to paste.* | + | *middle-mouse button (or shift + insert) paste from external linux clipboard after selecting the text to paste.* ** |
- | This is just a basic list of commands I frequently use. The line marked with asterisks is actually a linux shortcut, but it's very useful in Vim/GVim. | + | :e - ouvrir ; |
+ | :q - quitter [Ndt : dans la version 7.2, c'est :qa] ; | ||
+ | Échap - sortir d'un mode ; | ||
+ | i - mode insertion (sera inséré avant la sélection actuelle ; | ||
+ | a - mode ajouter ; | ||
+ | r - mode remplacer ; | ||
+ | u - annuler ; | ||
+ | ctrl+r - refaire [Ndt : dans la version 7.2, c'est ^R] ; | ||
+ | p - coller tout ce qui a été copié ou supprimé dans Vim/GVim ; | ||
+ | :hardcopy - Imprimer [Ndt : dans GVim en français, il y a une icône pour imprimer, ou Fichier > Imprimer ; | ||
+ | : | ||
+ | :set < | ||
+ | ctrl+v - mode visuel, ce qui permet la mise en surbrillance de lignes multiples à l' | ||
+ | I - insérer avant toutes les lettres en surbrillance. | ||
+ | X - supprimer toutes les lettres en surbrillance. | ||
+ | *bouton du milieu de la souris (ou maj + insérer) pour coller à partir du presse-papiers linux externe après avoir sélectionné le texte à coller.* | ||
+ | |||
+ | **This is just a basic list of commands I frequently use. The line marked with asterisks is actually a linux shortcut, but it's very useful in Vim/GVim. | ||
How do I use Vim/GVim? | How do I use Vim/GVim? | ||
To open a file, you can either append the path after the Vim/GVim command, or open it using :e once it loads. Once you have opened the file that you want to edit, you can then hit “i” (the key on the keyboard) to enter insert mode. It will tell you what mode is active (blank means there is currently no mode being used) in the bottom-left corner. For the sake of this example, let us simply write “Com3mand 6 Conque”. Once you've entered the text, it's time to fix it up. Move to the 3 using the hjkl keys, and then hit the “x” key to delete it. Head over to the 6 and hit the “r” key, and then enter the ampersand (“& | To open a file, you can either append the path after the Vim/GVim command, or open it using :e once it loads. Once you have opened the file that you want to edit, you can then hit “i” (the key on the keyboard) to enter insert mode. It will tell you what mode is active (blank means there is currently no mode being used) in the bottom-left corner. For the sake of this example, let us simply write “Com3mand 6 Conque”. Once you've entered the text, it's time to fix it up. Move to the 3 using the hjkl keys, and then hit the “x” key to delete it. Head over to the 6 and hit the “r” key, and then enter the ampersand (“& | ||
- | and you'll notice that you can't move the cursor past the already entered text. How do you enter the r then? You can either hit the “i” key for insert and move the cursor using the arrow keys and then enter it. Or, you could “append” the text using the “a” key, which moves the cursor to the space after the selected letter. Then type “r” and you're all set. If you want to save it, do so with :w (and if you haven' | + | and you'll notice that you can't move the cursor past the already entered text. How do you enter the r then? You can either hit the “i” key for insert and move the cursor using the arrow keys and then enter it. Or, you could “append” the text using the “a” key, which moves the cursor to the space after the selected letter. Then type “r” and you're all set. If you want to save it, do so with :w (and if you haven' |
+ | |||
+ | Ceci n'est qu'une liste de base des commandes que j' | ||
+ | |||
+ | Ma façon d' | ||
+ | Pour ouvrir un fichier, vous pouvez soit en ajouter le chemin après la commande Vim/GVim, soit l' | ||
- | A few things to remember: | + | **A few things to remember: |
The Vim shortcut keys that use letters (u, ctrl+r, y, d, w, etc) all require you to be in the “blank mode” (i.e. without any editing mode active). Otherwise, you'll just type the letter. Get in the habit of hitting escape after you've made a change so that you don't start typing in gibberish. | The Vim shortcut keys that use letters (u, ctrl+r, y, d, w, etc) all require you to be in the “blank mode” (i.e. without any editing mode active). Otherwise, you'll just type the letter. Get in the habit of hitting escape after you've made a change so that you don't start typing in gibberish. | ||
Ligne 63: | Ligne 109: | ||
http:// | http:// | ||
Screenshot (full-size): | Screenshot (full-size): | ||
+ | http:// | ||
+ | |||
+ | Voici quelques points à ne pas oublier : | ||
+ | Les raccourcis clavier de Vim qui utilisent des lettres (u, ctrl+r, y, d, w, etc.) nécessitent d' | ||
+ | |||
+ | L' | ||
+ | |||
+ | Si vous voulez copier quelque chose et voyez que vous copiez également le nombre des lignes, il suffit de les désactiver avec :set nonumber et de les activer à nouveau avec :set number. | ||
+ | |||
+ | Si vous avez des questions ou aimeriez un deuxième article sur Vim avec un exemple étape par étape, veuillez me le faire savoir à lswest34@gmail.com. Et si vous m' | ||
+ | |||
+ | Fichiers : | ||
+ | Mon .vimrc (J'ai supprimé quelques fonctions qui nécessitent des logiciels externes ou sont, en principe, à utiliser avec Mutt ; il pourrait en résulter qu'un ou deux réglages ne fonctionnent pas) : | ||
+ | http:// | ||
+ | Les couleurs dont je me sers (voir la capture d' | ||
+ | http:// | ||
+ | Capture d' | ||
http:// | http:// | ||
+ | |||
+ |
issue54/c_c.1320165348.txt.gz · Dernière modification : 2011/11/01 17:35 de auntiee