This is for C coding, but would apply to editing many languages. I often use ctags or lately cscope to jump around, and find I often need to quickly check or learn what function I am in.
A great tool that seems well suited to this is [[
(which goes to next {
in column 1)
Then you instantly jump back to where you were with ''
(two single quotes)
However, you need some customizations to make this work for my purpose. Depending on the size of the function, and where you are on the screen, vim has some rules (that I don't know much about) about when to centre your cursor depending on how far you moved with your last jump or search type of thing. In many cases, I found [[
would end up on the very first line of the screen, with the function name I so desired being just one hidden line above.
The last place I worked, the coding style was
return_type function_name ( type arg1, type arg2, type arg3, ... )
{
with the meat of it always on one line. So I :set scrolloff=1 and this system worked super-well. Barely noticeable in situations where I didn't need scrolloff set at all.
Now I see
return_type function_name ( type arg1,
type arg2,
type arg3,
... )
{
So I don't really want to set scrolloff=5 which would catch most situations, because in all the situations with only 1 or 2 arguments, and all the times I'm not searching for functions, I don't really want to necessarily waste that much screen real estate where my cursor could go without forcing VIM to scroll automatically.
Any ideas? I'd prefer a straight command or setting modification, but if script or function stuff is needed, so be it.