VIM Toolkit Functions

24 July 2008
by Billy Czajkowska

General-purpose functions for building up more useful VIM scripts.
” Move the cursor up a line
func Up()
exe “normal k”
endf
” Move the cursor down a line
func Down()
exe “normal j”
endf
” Cut the selected buffer text to the windows clipboard
func! Cut()
exe “normal “+x”
endf
” Copy the selected buffer text to the windows clipboard
func! Copy()
exe “normal “+y”
endf
” Paste windows clipboard data to the current buffer
func! Paste()
exe “normal “+gP”
endf
” Select all text in the editor’s current buffer
func! SelectAll()
exe “normal ggVG”
endf
” Wrapper function to write a string to the buffer
func! Print(str)
exe “normal o” . a:str . “”
endf
” Wrapper function to write a string to the buffer
func! P(str)
call Print(a:str)
endf
” Write a newline character to the buffer
func! NL()
call P(“”)
endf
” Write a newline character to the buffer
func! CR()
call NL()
endf

Our Latest News