Hi,

R. Hicks schrieb:
> Jürgen Krämer wrote:
>>
>> R. Hicks wrote:
>>> function! AppendModeline()
>>>    let save_cursor = getpos('.')
>>>    let append = ' vim: set et ts='.&tabstop.' sw='.&shiftwidth.' 
>>> tw='.&textwidth.': '
>>>    $put =substitute(&commentstring, '%s', append, '')
>>>    call setpos('.', save_cursor)
>>> endfunction
>>> nnoremap <silent><Leader>ml :call AppendModeline()<CR>
>>>
>>> I picked that up from the Vim wikia tips page. I like it but I would 
>>> like it to add a blank line before it places the text.
>>>
>>> The current version:
>>>
>>> 01: use strict;
>>> 02: # vim: et ts=# sw=# tw=#
>>>
>>> I would like:
>>>
>>> 01: use strict;
>>> 02:
>>> 03: # vim: et ts=# sw=# tw=#
>> just put a "\n" at the start of the append variable:
>>
>>     let append = "\n" . ' vim: set et ts='.&tabstop.' sw='.&shiftwidth.' 
>> tw='.&textwidth.': '
>>
>> The "\n" is a placeholder for a new-line character and when the variable
>> is put into the buffer you will get an additional empty line.
>>
> 
> I am pretty sure I tried that but because the append comes after the 
> &coomentstring in the substitute command I get:
> 
> #
>    vim: et ts=# sw=# tw=#
> 
> and not the empty newline then the comment string.

sorry, I didn't look close enough at the call to substitute(). Replace

  let append = ' vim: set et ts='.&tabstop.' sw='.&shiftwidth.' 
tw='.&textwidth.': '
  $put =substitute(&commentstring, '%s', append, '')

with

  let append = ' vim: set et ts='.&tabstop.' sw='.&shiftwidth.' 
tw='.&textwidth.': '
  let append = "\n" . substitute(&commentstring, '%s', append, '')
  $put =append

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.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to