Hi,
I am trying to write a vim autocmd script to add a default template to any file which opens with a specific extension and update some fields of this template when ever it is saved.
Some fields include, Modified data and modified by.
I was able to do it successfully.
This is the issue i have.
I am working in a linux based environment.
However, i have added a field called Modified by: in that template which needs to be automatically updated based on the user name who saves it.
I tried to achieve this by using an environment variable called $LOGNAME.
This is working for the first time save operation only.
When ever when i modify the which was written in the modified by field, name and save it, it is not able to overwrite the old name with the user name who modified it.
The same concept works perfectly well when trying to update modified date using $strftime
//Following is the piece of code that i am using.
let user_name = $LOGNAME
autocmd Bufwritepre,filewritepre *.sv
autocmd Bufwritepre,filewritepre *.sv exe "1," . 30 . "g/Last Modified :.*/s/Last Modified :.*/Last Modified : " .strftime("%c")
autocmd Bufwritepre,filewritepre *.sv exe "1," . 30 . "g/Modified By :.*/s/Modified By :.*/Modified By: " .expand("$LOGNAME")
autocmd bufwritepost,filewritepost *.sv execute "normal `a"
Please let me know what went wrong.
I tried using system functions like "whoami" etc, but i might be missing at the syntax
Thanks,
Srikanth
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Tuesday, July 20, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment