Hi,
Michael Henry schrieb:
> On 10/16/2010 05:20 AM, rameo wrote:
>> I created a script to delete the current file
> [...]
>> I only would like to insert the current filename in the question:
>>
>> Are you sure to delete this file? -->
>> Are you sure to delete "filename.ext"?
>
> You can change your variable assignment to the following:
>
> let g:delete_dialogue = 'Are you sure to delete "' . @% . '"'
this would only work correctly for the first call of s:Deleter(), because
after the first call g:delete_dialogue would include the name of the first
file to be deleted.
If the test at the start of s:Deleter() was put there to be able to set
the text of the question from the OP's ~/.vimrc I'd suggest to use a
string with a placeholder which can be replaced with the actual filename
when s:Deleter() is called. As there already is the builtin printf()
function, "%s" would be a good choice. Putting this together with
Michael's and ZyX' suggestion the OP's function might look like this:
fun! s:Deleter()
if !exists("g:delete_dialogue")
let g:delete_dialogue = 'Are you sure to delete "%s"?'
endif
if !exists("g:confermdeletefile")
let g:confermdeletefile = "&Yes\n&No"
endif
let question = printf(g:delete_dialogue, fnamemodify(@%, ':t'))
let f = confirm(question, g:confermdeletefile, "Question")
if f == 1
:silent exe "echo delete(@%)"
echo (@%) "deleted"
exe "bw!"
elseif f == 2
return
endif
endfun
Now if I wanted to use this function I could put
let g:delete_dialogue = 'Möchten Sie "%s" wirklich löschen?'
in my ~/.vimrc and would get the question in German.
Regards,
Jürgen
--
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)
--
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