Saturday, June 19, 2010

Wanted: smart selective abbreviation loading

The following may be totally daft, something others
might find useful, or even already existing. Whichever
it may be I'd appreciate info on where to find it, how to
implement it, or reasons not to implement it.

TIA,

/BP

Since I write files in many different languages, both
in the computer language and natural language sense,
and on different more or less unrelated subjects I
often want to use different sets of abbreviations, so I
would like to have a plugin defining a command

:Labbr string [string]...

(where strings may contain wildcards) which causes vim
to do the following:

a. For each string look for files with names matching

string.abbr

in the following places, in order:

1) the directory of the current file if the buffer
has been saved.
2) ~/.abbr if it exists.
3) Subdirectories of (2).

b. Scan found files for lines matching

/^\s*\(\w\+\):\s\+\([^#]\+\)/

c. For each found line do (what I mean by)

:abb <buffer> \1 \2

(I don't know if you can use \1 and \2 like that but
you know what I mean! :-)

The idea is that I may have files like

current_file_dir/sv.abbr

~/.abbr/subject_sv.abbr

~/.abbr/sv.abbr

~/.abbr/**/subject_sv.abbr

which will be processed as per above if i say

:Labbr subject_sv sv

The point of not just sourcing *.vim files with :abb
commands is of course that the same files may be used
for similar purposes by other programs. I typically
write text in the notes thingy on my smartphone, email
the text to myself (over the wlan when I get home ;-),
then use a Perl script which works essentially like the
vim plugin I crave -- and so obvious from the spec that
I'll not waste bandwidth by including it -- to expand
any abbreviations in the text written on the phone, and
I want to be able to use the the same abbreviations and
the same abbreviation definition files (which actually
are YAML mapping fragments, btw! :-) when typing in
vim.

--
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: