Tuesday, September 1, 2009

Re: How to check file is modified or open in 2 or more windows?

Miao Jiang wrote:
> I want to write a function which do
> if the file is modified
> if there is 2 or more windows of that file
> exec 'e .'
> else
> split window
> exec 'e .'
> endif
> endif
>
> Thanks
> Miao
>
>
> >
>

solved.

check file modified or not use &modified
check window numbers of buffer
I write a function.
function GetWindowCount(expr)
let cur_buf_id=bufnr(a:expr)
let cur_buf_cnt=0
let i=1
while 1
let buf_id=winbufnr(i)
if buf_id==cur_buf_id
let cur_buf_cnt=cur_buf_cnt+1
endif
if buf_id==-1
break
end
let i=i+1
endwhile
return cur_buf_cnt
endfunction


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

No comments: