Tuesday, December 26, 2006

VIM: vimrc function to set file name

This function replaces the existing file name with the name of the file stored in register %.
The file should have the file name after "Module" word for this function to work properly.

function! ReadFileName()
let l:linenum = search("^// *[Mm]odule","w")
let l:filename = getreg("%")
let l:newline = '// Module : '.filename
sil exe ":call setline( linenum, newline)"

No comments:

Post a Comment