editing ChangeLogs with Vim?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

editing ChangeLogs with Vim?

Maciej Kalisiak-3
Is there any special handling for editing ChangeLog files in Vim?  If not,
can anyone who does use Vim to maintain ChangeLogs share any effective tips
& tricks they use?
Reply | Threaded
Open this post in threaded view
|

Re: editing ChangeLogs with Vim?

François Pinard
[M.K.]

> Is there any special handling for editing ChangeLog files in Vim?

Yes.

> [...] can anyone who does use Vim to maintain ChangeLogs share any
> effective tips & tricks they use?

I do not know how useful these might be, but here is what I use.  It may
give you ideas.  Suggestions welcome!  A few comments follow at the end.

File ~/.vim/plugin/changelog.vim:

---------------------------------------------------------------------->
runtime! ftplugin/changelog.vim

let g:changelog_username = 'Fran?ois Pinard  <[hidden email]>'
----------------------------------------------------------------------<

File ~/.vim/plugin/spell.vim:

---------------------------------------------------------------------->
function Set_spell()
  if version >= 700
    let langue = input("Langue? [, en, fr] ", "")
    if langue == "f" || langue == "fr"
      setlocal spell spelllang=fr
    elseif langue == "e" || langue == "en"
      setlocal spell spelllang=en
    endif
  endif
endfunction
----------------------------------------------------------------------<

File ~/.vim/ftplugin/changelog.vim:

---------------------------------------------------------------------->
if &filetype != 'changelog'
  finish
endif

call Set_spell()
setlocal noexpandtab
----------------------------------------------------------------------<

File ~/.vim/syntax/changelog.vim:

---------------------------------------------------------------------->
highlight! link changelogTemps WarningMsg
highlight! link changelogReported WarningMsg

syntax match changelogTemps "([0-9][0-9]*h)"
syntax match changelogTemps "([0-9][0-9]*\.[0-9]*h)"
syntax match changelogReported "Reported by"
----------------------------------------------------------------------<

The `runtime! ...' line is for activating the `\o' command globally.
`\o' (that is, backslash followed by letter o) is the magic keybinding
to start a new ChangeLog entry.

`Set_spell' is meant to interactively decide which language (English or
French, or none) should be used to spell files being edited.  I call
Set_spell() in many ftplugins.  It could be removed of course.

The `finish' is for preventing `Set_spell' from being called at the time `\o'
is being activated globally, as above.

For my free software projecs, "Reported by" strings also highlighted, as
a way to underline contributors.  For my other projects, strings like
"(2.5h)" are especially highlighted, as I process all such ChangeLogs,
once per month, for billing purposes.  The highlight is a feedback
telling me I entered these annotation in the proper format.

--
Fran?ois Pinard   http://pinard.progiciels-bpi.ca