VIm notes
From IdeaNet
Jump to navigationJump to search
- apply a script file of ex commands ex_command to a given file my_file
- on the command line:
user@host:~$ vim -S ex_command my_file
- inside VIm, in ex mode:
:source! ex_command
- sort lines 1 to 30 using external command
:1,30!sort
- usefull commands (in command mode)
gt will go to the next tab gT will go to the previous tab
- save the file with root privileges using sudo
:w !sudo tee %
- interesting options
Description enable disable enable (short form) disable (short form) auto-indentation :set autoindent :set noautoindent :set ai :set noai case-unsensitivity :set ignorecase :set noignorecase :set ic :set noic line number display :set number :set nonumber :set nu :set nonu
- spell cheking
- to enable:
:set spell spelllang=en_us # enable US english spell checking :set spell spelllang=fr # enable french spell checking :setlocal spell spelllang=fr # enable french spell checking for the current view
- to disable:
:set nospell
- dictionary files
- Dictionnaries can be found at http://ftp.vim.org/vim/runtime/spell/
- New dictionnaries (*.spl and *.sug files) must be copied inside ~/.vim/spell
- to get propositions about a misspelled word hit z=
- folding commands
- zfnj creates a fold from the cursor down n lines.
- zo opens a fold on the cursor.
- zj moves the cursor to the next fold.
- zk moves the cursor to the previous fold.
- zd deletes the fold at the cursor.
- zE deletes all folds in the document.
- zM closes all open folds.
- zR opens all folds.