Vim: Difference between revisions
Line 21: | Line 21: | ||
= Locations = | = Locations = | ||
<blockquote> | <blockquote> | ||
{| | |||
{| | |||
|- | |- | ||
| | !colspan=2| Unix | ||
|- | |- | ||
| <code>~/.vim</code>< | | <code>~/.vimrc</code> || config | ||
<code>%HOMEDRIVE%%HOMEPATH%/vimfiles</code> | |- | ||
|| plugins, | | <code>~/.vim</code> || libraries, syntax, help, plugins, ... | ||
|- | |||
!colspan=2| Windows | |||
|- | |||
| <code>%HOMEDRIVE%%HOMEPATH%/_vimrc</code> || config | |||
|- | |||
| <code>%HOMEDRIVE%%HOMEPATH%/vimfiles</code> || libraries, syntax, help, plugins, ... | |||
|- | |- | ||
|} | |} |
Revision as of 17:46, 17 July 2021
A fast, customizable, cross platform mode based text editor that usually runs in a console.
Vim is uniqe in that it is modal:
- text is written in insert mode
- navigation is performed in normal mode
- selections made in visual mode
- commands entered in command mode
Each has it's own keybindings.
Documentation
:help
https://vimhelp.org/
Locations
Unix ~/.vimrc
config ~/.vim
libraries, syntax, help, plugins, ... Windows %HOMEDRIVE%%HOMEPATH%/_vimrc
config %HOMEDRIVE%%HOMEPATH%/vimfiles
libraries, syntax, help, plugins, ...
Basics
vim intro vim install
Usage
vim commandline vim diff
Configuration
viml vim keybindings vim plugins
Components
vim commands vim filetypes vim folding vim buffers vim registers vim macros vim ctags
Behaviour
Buffers
Buffers are any text that vim stores. It is typically associated with a file
Registers
Registers are places where you can copy text to for processing. There is the system clipboad register, the standard vim register, named registers, etc. Registers are accessed by using
"
followed by a letter(the register), and then the operation you want to perform on it. When yanking, if you use a capital letter, you will append to your register instead of replacing it.@ ""The yank-text register "zyy ""Copy Line under text to register 'z' "Zyy ""Append Line under text to existing register 'z' "zp ""Paste register 'z' let var = @z ""Save contents of register 'z' to a variableYou can also record expressions to registers.
let @* = expand('%:p') " copy current filepath to clipboardFiletypes
sometimes you want to use syntax highlighting for files that aren't really programs. sometimes you want certain programs to be recognized as their proper filetype while using a different extension.
set filetype=python #sets current filetype to python set filetype=? #query current filetype au BufRead,BufNewFile *.cpy set filetype=python #auto associate filetypes with extensions (in your .vimrc)Macros
q<letter> # start recording macro bound to <letter> q # stop recording @<letter> # play-back recording