Long time no post in here, sorry.
Since I’ve had the chance to review Kim Schulz’s Hacking Vim 7.2 ebook1 and a friend of mine started using vim as his main development tool, digging into Vim’s configurations and flavours has become somewhat even more pleasant.
In an attempt to improve my performance when editing various files, I’m trying to use tabpages instead of only several windows. It’s been working as some kind of context stack for me, as there can be one tabpage (probably with fewer windows) for modifying files from a project and another tabpage for a different but related one (or a non-related task in the same project). Plus, using more tabpages and less windows can save precious screen space.
But what to do about that odious tabline which, besides hurting my sense of aesthetics, eats a whole line of the screen? Thankfully to the Vim’s extremely flexible nature, it didn’t take long to find an answer. It came in form of disabling the tabline entirely and putting its only usable information into the statusline. Used a bit of scripting to overcome the only corner case I could think of and took the chance to try my rusty skills on python + vim bindings. Pretty much everything someone will need to put both domains together is in this little example (besides the vim module complete API, easily accessible by issuing :h python).
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
function! MyTabMarker(disable)
python << EOF
import vim
def tabpagecount():
return int(vim.eval("tabpagenr('$')"))
def tabpage():
return int(vim.eval("tabpagenr()"))
def tabmark():
disable = int(vim.eval("a:disable"))
if tabpagecount() > 1 and not disable:
return "\"[tab %d/%d] \"" % (tabpage(), tabpagecount())
return "\"\""
vim.command("return " + tabmark())
EOF
endfunction
set laststatus=2
set showtabline=0
set statusline=#%02n\ %{MyTabMarker(0)}%f\ %m%r%y%=\(%bd,%Bh)\ %c,%l/%L\ %P |
There you see how to pass arguments into python methods and how to feed values back from it to the vim environment. Eventually I’ll publish my entire .vimrc with comments so everyone can rant about how theirs way is better
[1] as I’ve lost my notebook due to a robbery at the technical assistance, my review annotations were lost too. I’ll need to re-review the book to get something published about it then.