Vim and 750 words

Vim, functions, 750words and all-all-all

I really love writing, mostly on russian. Also my English still not really good and I plan to improve it. I heard about 750word program, but I certainly don’t want to use another service for writing, I’m stingy)

Fast research

I found a nice project on GitHub called 750words 1

But I need some improvements:

  • Vim status bar should display how many words I need to write
  • custom status bar will be displayed if I do a writing

Lets go. First I check a stack overflow and yes, job was already done by someone2:

function! WordCount()
  let s:old_status = v:statusmsg
  let position = getpos(".")
  exe ":silent normal g\"
  let stat = v:statusmsg
  let s:word_count = 0
  if stat != '--No lines in buffer--'
    let s:word_count = str2nr(split(v:statusmsg)[11])
    let v:statusmsg = s:old_status
  call setpos('.', position)
  return s:word_count 

:set statusline=wc:%{WordCount()}

Now next round - how to apply settings right way. Here is a two different way - based on extension or based on project

One nice little feature of good old VI is to allow configuration per folder. Everything you need to do is >just place .exrc file in the current folder and kick off VI. This feature still exists with VIM, but is >disabled by default. To enable it, just set exrc and VIM will respect custom configurations in current >directory

I prefer to use a one rc per project, that is a most powerful way than fix vimrc in common every time Adding a vim-localrc to Janus plugins: mkdir ~/.janus; cd ~/.janus git clone

Then adding a .local.vimrc with function and modeling to ~/.750words directory Testing a function: :call WordCount()

Its working! Pull request to Denton was sent.