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
gggo to the beginning of file
Ggo to the end of file. Preceded by quant. go to line number
zzput the current line at the center of the screen
CTRL-Ogo to the [count] previous position
changing
Jjoin lines
ccchange whole line
windows
CTRL-W ssplit window
inserting
IInsert text at the beginning of the cursor line
AAppend 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
[IShow 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
]IShow 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-IJump to the first line that contains the keyword under the cursor, starting at the beginning of the file
] CTRL-IJump 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-pCTRL+n : keyword completion (with strings found in the text). CTRL+p : go back
divers
gaaffiche 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-Trevenir 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

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.

 
libre/vim.txt · Dernière modification: 2006/05/09 15:47 (édition externe)