Vim integration

Typing and remembering the exact spelling of the long actions can be less than fun sometimes. This quick "howto" shows how to set up completion of "opera actions" in vim. For now I assume a unix like enviroment. (will try to fix this later)

fun! CompleteOperaActions(findstart, base)
	if a:findstart
		if getline(".")[col(".") - 2] !~ '[A-Za-z]'
			return col(".")
		endif
		let line = line('.')
		call search('[^A-Za-z ]', 'b', line)
		call search('[A-Za-z]', '', line)
		let start = col('.')-1
		return start
	else
		" inefficient matching
		let res = []
		for m in readfile(expand("~/.vim/opera_actions"))
			if m =~ '^' . a:base
				call add(res, m)
			endif
		endfor
		return res
	endif
endfun
set completefunc=CompleteOperaActions

I threw this together pretty quick. Let me know if you find bugs.

There is one comment on this page. [Display and/or add comments]