T,c, |
Delete between coma |
:b#<bar>bd# |
delete buffer |
C |
= c$ : Change to end of line |
S |
= ^C : Change from first non blank to EOL |
gq motion |
Filter format |
g= motion |
Filter indent |
!<motion><cmd> |
Filter |
'. |
Last edit location |
g- |
Last non blank character (Vs _ or ^ ) |
gm |
Middle of line |
n<bar> |
Column n of current line |
ab aB |
Select a block ( ), a block { } |
- + |
line up, down on first non-blank character |
zl, zh, zL, zH |
Scrool horizontally, one char or screen |
zt , zz , zb |
Cursor top middle, bottom |
<C-W>Z |
:pc[lose] : Close previw window |
1gt |
Goto tab 1 |
:w !sudo tee % |
Save as root |
:set nrformat+=alpha |
<C-A> works with alphabet chars |
:sort [u] [n] |
Sort [Unique] [Numerals (so 100 after 20) |
:echo 5e9x20 |
Simple Math |
:q: , q/ |
Ex, Search Windows |
normal @a |
Execute register a in this line |
g/{/_.+1,/-1 sort |
Sort between { and } |
:sort n/\(\S\+\s\+\)\{2}/ |
Sort by 2nd column |
:%s/^/\=printf('%-4d', line('.')) |
Prefix line by line number |
:set fo+=t |
Autowrap (h formatoption ) |
:bro[wse] ol[dfiles][!] |
Prompt which file to choose |
:earlier 12h |
Change file to how it was 12h ago |
:%! column -t |
align columns |
:syntax sync fromstart |
Reload syntax |
set cul! |
if scrooling slow for a long line |
set lazyredraw |
can be usefull too |
h ttyfast |
:v/./,/./-j |
Compress multiple blank lines into on |
Some usefull function * Function: sort(list), put, getline(int), setlone(int, list) join(list), split(string), len(list), get, getpid()
:%s/.*/\=printf("%03d", len(submatch(0)) . "|" . submatch(0)/ | sor n | %s/..../
:%!tac
:%!tail -r
:g/^/m0
runtime! ftplugin/man.vim
:Man 3 printf
set autochdir " auto chdir to current file
:tabdo lcd /dir/
:%sno/search_string/replace_string/g
:s/</\='<'/g
:%s/\(^\|\(text\)\@<=\).\{-}\($\|text\)\@=//g
text \(^\|\(text\)\@<=\) # means start of line, or some point preceded by “text” .\{-} # as few characters as possible \($\|text\)\@= # without globbing characters, checking that we reached either end of line or occurrence of “text”.
:%s/.*/\=repeat('text', matchcount('text', submatch(0)))
:g/\v^([^ -=]+)\n\_.*%(^\1$)/d
vo , vO |
Goto other side of visual selection |
gv |
Reselect las selection |
g* , g# |
Search word under cursor but without delimiter |
/.\{-}toto |
Non greedy, get first occurent of toto |
:& |
Repeat las substitution |
:hi visu ctermgg=Cyan
:match visu /\%<13c/
:h /\%
222go |
Goto byte 222 |
xxd
-r (reverse, from hex to string) -p (output in ps := raw) -c 8 (bytes per line) -g 1 (bytes per column)vim -b file
or set binary
:set noeol
or set nofixendofline
TODO
/\%xYY |
YY hex ord(ascii) |
/\%uYYYY |
hex ord(unicode) |
[[=a=]] | Character (a) equivalentce class (so get à) | | /| Match letters in latin see :echo &isident| | s/%V| Substitute within selection | | /%<13c` |
Before 13 virtual column |
/^[a-zàâçéèêëîïôûùüÿñæœ .-]*$/i
:!
: Get last outputredir @a
echo toto
redir END
let @a=getcwd()
:@"
: Execute what is yanked
"Examples:
":call Exec('buffers')
"This will include the output of :buffers into the current buffer.
"Also try: ":call Exec('ls')
":call Exec('autocmd')
funct! Exec(command)
redir =>output
silent exec a:command
redir END
let @o = output
execute "put o"
endfunct!
TODO ### Inspect syntax highlight (link)
map K :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>
To find the script file defining a map : :verbose map <c-z>
. But map
can ber replaced by:
abbreviate
, autocmd
, command
, function
, let
, set all
.
jumps
, marks
, args
, changes
digraphs
, highlight
, reg
, scriptnames
, spellinfo
, `syntax
Find where root runtime is
:echo $VIMRUNTIME
-> /usr/share/vim/vim74
Source autoload file
:call example#BadFunction()
* `:let bufFiletype = getbufvar(bufNr, '&filetype')`
:echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
:let bufFiletype = getbufvar(bufNr, '&filetype')
:au FileTypepyrhon setlocal formatprg=autopep8\ -
xnoremap p pgvy
: Copy without yanking selection in visual:set guioptions-=m " remove menu bar
:set guioptions-=T " remove toobar
:set guioptions-=r " remove right hand scrool bar
:set guioptions-=L " remove lefthand scrooll bar
ab |
abbrev |
a |
append |
ar |
args |
c |
change |
co |
copy |
t |
Copy line to |
d |
delete |
e |
edit |
f |
file |
g |
global |
i |
insert |
j |
join |
l |
list |
maa |
map |
ma |
mark |
m |
move |
n |
next |
nu |
number |
o |
open |
pre |
preserve |
p |
|
pu |
put |
q |
quit |
re |
read |
rec |
recover |
rew |
rewind |
se |
set |
sh |
shell |
so |
source |
st |
stop |
s |
substitute |
una |
unabbrev |
u |
undo |
unm |
unmap |
ve |
version |
vi |
visual |
w |
write |
x |
xit |
ya |
yank |
z |
window |
! |
escape |
CR |
print next |
& |
resubst |
> |
rshift |
^D |
scroll |
vim -u NONE -N
# No (User) vimrc, Non-compatibleecho toto | vim -
: take arguments from stdinecho foo | vim -e '+%print' '+q!' /dev/stdin
: exmode to not consume stdin and not clear output on quitvim <(echo toto)
: process substitution command (BaSh):w !tee
: write to stdout:w !sh
: write to shell inputvim --servername DEMO
vim --servername DEMO --remote file.txt
vim --servername DEMO --remote-send ":3d<CR>"
:!vim --servername DEMO --remote-tab "%" " Send current buffer to remote vim
Dos2Unix: for file in * ; do vi +':w ++ff=unix' +':q' $file