nvim/viml/automacro.vim

33 lines
560 B
VimL
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

" various tools inside vim
function! GetCharUnderCursor()
let line = getline('.')
let col = col('.')
return line[col - 1]
endfunction
" predefined macros in functions
function SpacedLine()
normal o
normal O
normal O
normal j
endfunction
function SwapWords()
normal dw
normal e
exec 'normal! a '
normal p
normal l
let char = GetCharUnderCursor()
if char == ' '
normal x
endif
normal h
normal b
normal b
endfunction
let @o = ':call SpacedLine()
'
let @s = ':call SwapWords()
'