//VIM Toolkit Functions

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

By |2008-07-24T09:27:41+00:00July 24th, 2008|Vim|0 Comments

About the Author: