Vim Tips Wiki
Advertisement
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Tip 525 Printable Monobook Previous Next

created 2003 · complexity intermediate · author Lech Ambrzykowski · version 6.0


This one helps creating beans. Nothing serious actually, but might come in handy.

nnoremap <buffer> <silent>dc :call <SID>AddBean()<CR>
function! s:AddBean()
  let line = line('.')
  let name = inputdialog('Enter the name of the variable: ')
  let type = inputdialog('Enter the type of the variable: ')
  let upperName = substitute(name, '^\(\w\)\(.*\)$', '\u\1\2', '')
  call append(line, "\t}")
  call append(line, "\t\tthis.".name." = ".name.";")
  call append(line, "\tpublic void set".upperName."(".type." ".name.") {")
  call append(line, "")
  call append(line, "\t}")
  call append(line, "\t\treturn (this.".name.");")
  call append(line, "\tpublic ".type." get"."".upperName."() { ")
  call append(line, "")
  call append(line, "\tprivate ".type." ".name.";")
  call append(line, "\t//".name)
  return line
endfunction

Comments

You might be interested in http://www.ophinity.com/papers/wrangling/index.html#multiply

It's fairly generic but i use it to chug thru a list of values and apply those to a code-template. it lends itself to setters & getters.


Advertisement