Okay, I currently have a set up in vim so that when I type "<leader>ns" it takes any given
word and turns it into a sub "sub
word(){}". I also have it when I type "<leader>nc" it creates a doc comment section that is "blank". I was wondering if someone could help me out with combining the two so that when I typed <leader>ns it would create the doc comments with the word already in the Subroutine: line and create the new sub routine aswell. I'm trying to understand what I have (downloaded from the internet) and only doing so so. If someone could help explain how the vim function works, I might be able to go from there but I can't really find any relevant info online for it.
Code:
" Put cursor over word and hit ,ns to create new Sub
nmap <leader>nc o
#------------------------------------------------------------------------------
# Subroutine:
# Function :
# Parms :
# Returns :
# Assumes :
#------------------------------------------------------------------------------
nnoremap <Leader>ns :call Newsub()<CR>
function! Newsub()
let word = "sub " . expand("<cword>") . "()" . " {" . "}"
let ln = search("__.*__", 'nW')
if ln == 0
call append('$', word)
else
call append(ln-1, word)
endif
endfunction
(the <leader>nc is formatted in vim so that it creates it to look like that [aka, all one line with ctrl-v ctrl-m seperating them])
Thank you
RzITex