Outils pour utilisateurs

Outils du site


tech:notes_vim

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
tech:notes_vim [2025/05/28 17:11] Jean-Baptistetech:notes_vim [2026/06/07 19:12] (Version actuelle) – modification externe 127.0.0.1
Ligne 1: Ligne 1:
 +<!DOCTYPE markdown>
 +{{tag>vim}}
 +
 +# Notes vim
 +
 +Voir 
 +* [[notes_vimdiff]]
 +* https://doc.ubuntu-fr.org/vim
 +* http://david.blanchet.free.fr/vim/doc/fr62017/editing.txt.html
 +* vim-addon-manager
 +
 +
 +## Modeline magic
 +
 +~~~
 +# vim: ai:ts=4:sw=4
 +# vim: enc=utf-8:nu:ai:si:et:ts=4:sw=4:ft=xdefaults:
 +# vim: set ai et sts=2 sw=2 tw=80:
 +# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
 +# YAML
 +# .. vim: foldmarker=[[[,]]]:foldmethod=marker
 +~~~
 +
 +
 +vimrc
 +~~~bash
 +set modeline
 +set modelines=5
 +~~~
 +
 +
 +## vimrc
 +
 +vimrc
 +~~~
 +filetype plugin indent on
 +" show existing tab with 4 spaces width
 +set tabstop=4
 +" when indenting with '>', use 4 spaces width
 +set shiftwidth=4
 +" On pressing tab, insert 4 spaces
 +set expandtab
 +~~~
 +
 +
 +## Autres
 +
 +Debian est installé par défaut avec un vim allégé, le apt://vim-tiny
 +
 +Pour install le vrai apt://vim
 +
 +~~~bash
 +apt-get update && apt-get install vim
 +~~~
 +
 +Lancer le tutorat VIM 
 +~~~bash
 +vimtutor
 +~~~ 
 +
 +Ouvrir plusieurs fichiers simultanément - cote à cote comme avec vimdiff
 +~~~bash
 +vim -O fic1.md fic2.md
 +~~~  
 +
 +Ouvrir plusieurs fichiers simultanément - l'une au-dessus des autre
 +~~~bash
 +vim -o fic1.md fic2.md
 +~~~
 +
 +
 +Vim suppression de lignes avec motif
 +~~~
 +:g/toto/d
 +~~~
 +
 +~~~
 +u : Undo (Annulez une modif, "édition-précédent")
 +Ctrl-R: Redo changes (Annulez le annuler précédent)
 +~~~
 +
 +Display non-printable character
 +~~~
 +:set list
 +:set display+=uhex 
 +~~~
 +
 +Commande, trie 
 +~~~
 +:%ls
 +:%!sort -r
 +~~~
 +
 +Voir également
 +~~~
 +$ cat hidden.txt
 +ab
 +$ wc --char hidden.txt
 +5
 +$ sed 's/\o302\xAD//' hidden.txt > fixed.txt
 +wc --char fixed.txt
 +3
 +~~~
 +
 +
 +File browser
 +~~~
 +:Ex 
 +~~~
 +
 +for ex(ploring) the file directory.
 +
 +
 +Alternative
 +~~~bash
 +sudo update-alternatives --config editor
 +~~~
 +
 +
 +## Insérer un caractère spécial comme un espace insécable
 +
 +~~~
 +Use CTRL + K
 +
 +Ex with non-breakable space
 +CTRL + K, <SPACE>, <SPACE>
 +~~~
 +
 +
 +## Pb
 +
 +### Pb Debian Stretch (Debian 9) Copier-coller ne fonctionne pas avec la souris
 +
 +Source : 
 +* https://unix.stackexchange.com/questions/318824/vim-cutpaste-not-working-in-stretch-debian-9
 +* https://stackoverflow.com/questions/4608161/copy-text-out-of-vim-with-set-mouse-a-enabled
 +
 +** Solution : Il suffit de maintenir la touche Shift enfoncée lors de la sélection du texte**
 +
 +Ou alors pour avoir le même comportement que Debian Jessie : 
 +
 +`/usr/share/vim/vim80/defaults.vim`
 +~~~
 +" In many terminal emulators the mouse works just fine.  By enabling it you
 +" can position the cursor, Visually select and scroll with the mouse.
 +"if has('mouse')
 + set mouse=a
 +"endif
 +~~~
 +
 +Correction avec Ansible
 +~~~yaml
 +- name: bugfix vim
 +  replace:
 +    dest: /usr/share/vim/vim80/defaults.vim
 +    regexp: '^\s+set mouse=a'
 +    replace: '"  set mouse=a'
 +  when:
 +    - ansible_os_family == 'Debian'
 +    - ansible_distribution_major_version == '9'
 +~~~
 +
 +Ou 
 +~~~bash
 +echo "set mouse-=a" >> ~/.vimrc
 +~~~
  

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki