VIM est le meilleur éditeur de texte qui ait jamais existé… en tout cas avec lequel j'ai jamais travaillé.
My personal Vim reference card
| moving | |
|---|---|
| gg | go to the beginning of file |
| G | go to the end of file. Preceded by quant. go to line number |
| zz | put the current line at the center of the screen |
| CTRL-O | go to the [count] previous position |
| changing | |
| J | join lines |
| cc | change whole line |
| windows | |
| CTRL-W s | split window |
| inserting | |
| I | Insert text at the beginning of the cursor line |
| A | Append text to the end of current line |
| searching | |
| * | Search forward for the [count]'th occurrence of the word nearest to the cursor |
| # | Search backward for the [count]'th occurrence of the word nearest to the cursor |
| [I | Show in the command window all the occurences of the word under the cursor in all the open files, beginning at the end of the file |
| ]I | Show in the command window all the occurences of the word under the cursor in all the open files, beginning at the current cursor position |
| [ CTRL-I | Jump to the first line that contains the keyword under the cursor, starting at the beginning of the file |
| ] CTRL-I | Jump to the first line that contains the keyword under the cursor, starting at the cursor position |
| code editing | |
| % | Find the next item (block or comment) in this line after or under the cursor and jump to its match |
| CTRL-n CTRL-p | CTRL+n : keyword completion (with strings found in the text). CTRL+p : go back |
| divers | |
| ga | affiche le code du caractère sous le curseur en ascci, hexa, octal |
| copy - paste | |
| :reg | display the content of registers |
| ”. | register: contains the last inserted text |
| use uppercase register letter to append (for delete and yank) | |
| navigation dans l'aide | |
| CTRL-] | suivre un lien de l'aide |
| CTRL-T | revenir sur le sujet précédent |
script for SQL
I've done a small [http://www.babaluga.com/code/vim/sqlcb.vim code beautifier] vim script for SQL, that for now mostly put keywords in uppercase. To use it, you can for example map it to a key in your [_.]vimrc like this :<br>
" SQL mappings :augroup filetypedetect :au BufNewFile,BufRead *.sql :map §1 :so c:\bin\vim\vimfiles\myscripts\sqlcb.vim<CR><CR> :augroup END
commands snippets
remove HTML tags from the next 20 lines
<pre>:.,+20s/<[\^>]*>//g</pre>
Sort lines
:'a,'b !sort to sort lines between markers a and b inclusive !12jsort to sort 12 lines, including the current one 12!!sort same as above :1,$ !sort to sort the whole file
Liens utiles
- [[http://www.rayninfo.co.uk/vimtips.html|David Rayner's Best of Vim Tips] ]
astuces pour Windows
- Intégration dans Total Commander : j'utilise Total Commander en permanence, et j'utilise Vim comme éditeur pour l'édition de fichiers à partir de Total Commander, via la touche F4. Depuis Vim 7.0, l'édition de fichiers en onglets dans Vim est une fonctionnalité standard. Afin d'ouvrir un fichier dans Vim sans ouvrir une nouvelle instance, et en chargant le fichier dans un nouvel onglet, j'ai ajouté à la ligne de commande d'appel de Vim dans Total Commander cette option :
--remote-tab-silent
qui appelle Vim en tant que serveur (OLE sur Windows) et charge le fichier dans un onglet. Le silent ajouté à la fin permet de ne pas générer un message d'erreur lorsqu'aucune instance de Vim n'est chargée. Si c'est le cas, Vim se charge. On peut certainement faire la même chose avec le menu contextuel que Vim ajoute à l'explorateur de fichiers Windows.



