> On Sunday, April 8, 2012 7:13:22 PM UTC-5, dotancohen wrote:
>>
>> :set statusline=%<%f%=%([%{Tlist_Get_Tagname_By_Line()}]%)
>>
>>
>> set statusline=%{PHP_Cursor_Position()}
>> function! PHP_Cursor_Position()
>> let pos = getpos(".")
>> let curline = pos[1]
>> let win = winsaveview()
>> let decl = ""
>> let startline =
>> search('^\s*\(static\|public\|private\)\=\s*\(static\|public\|private\)\=\s*\(static\|public\|private\)\=\s*\(function\|class\)\s*&\=\w\+','cbW')
>> call search('{','cW')
>> sil exe "normal %"
>> let endline = line(".")
>> if curline >= startline && curline <= endline
>> let decl = getline(startline)
>> endif
>> call cursor(pos)
>> call winrestview(win)
>> return decl
>> endfunction
>>
>
> Just a guess, but I'm betting one of these is causing your trouble. First I note with interest that the first of them is always overwritten by the second and thus shouldn't do anything. Then I note that the second will, every time the screen redraws, mess with the cursor position. Although it restores it later, I wonder if it causes problems anyway.
>
Those two statusline bits are some current experimentation of mine, I
don't ever have both of them enabled at once. But you are right,
putting "finish" before them fixes all the issues that I have been
noticing with VIM lately.
> I bet it would be possible to rewrite this in a way that it never moves the cursor, using the 'n' flag on the search() commands, and a searchpair() to replace the normal % command. But if it isn't actually the culprit of your jump position problems then it probably doesn't make sense to mess with it, if it works as intended.
>
I will have to look into that I am very new at VIM scripting but I am
diving in head first. VIM is quite a deep rabbit hole, it seems that
it can do almost anything so long as one is willing to experiment a
bit with the scripting.
Thanks!
--
Dotan Cohen
http://gibberish.co.il
http://what-is-what.com
--
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
No comments:
Post a Comment