Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Adding a prefix to certain filename completions



Peter Stephenson wrote:
> Nikolai Weibull wrote:
> > Ah, of course.  There are many commands that can use this actually.
> > :help ex gives the following list:
> > 
> > ex exim view gvim gex gview rvim rview rgvim rgview evim eview vimdiff gvimdi
> > ff
> > 
> > and, as you say, there's usually a vi link as well,
> 
> This adds the vim-specific versions.  ex and view also come with vi.
> I'll wait for someone to decide how to manage these three.
> 
> Index: Completion/Unix/Command/_vim
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_vim,v
> retrieving revision 1.1
> diff -u -r1.1 _vim
> --- Completion/Unix/Command/_vim	7 Jul 2005 11:16:11 -0000	1.1
> +++ Completion/Unix/Command/_vim	7 Jul 2005 12:51:01 -0000
> @@ -1,4 +1,4 @@
> -#compdef vim
> +#compdef vim exim gvim gex gview rvim rview rgvim rgview evim eview vimdiff gvimdiff
>  
>  _vim_files () {
>    if [[ $(echo $PREFIX*(N)) == '' ]]; then

This whole discussion reminds me of some stuff that I always
wanted to clean up a bit...
My _vimhelp still depends on $VIM to be set (parsing "vim
--version" output for vim's fallback for $VIM should be no
problem), and removing sed out of the $vimversion calculation
below could maybe also be done. Anyways... for those who think
this might be useful:

----------------------- _vimhelp ---------------------
#compdef vimhelp gvimhelp

local vimversion curcontext="$curcontext" context state line expl ret tagsfile

vimversion=$(vim --version |& head -1 | sed -e 's/VIM - Vi IMproved //' -e 's/ .*//' -e 's/\.//' -e 's/^/vim/')
tagsfile=$VIM/$vimversion/doc/tags

_vimhelp_update_tags() {
  if (( ! $+_vimhelp_tags )); then
    _vimhelp_tags=(
      $(cat $tagsfile | sed -e 's/	.*//')
    )
  fi
}
_vimhelp() {
   _vimhelp_update_tags
   compadd -- $_vimhelp_tags
}

_vimhelp "$@"
---------------------- / .zshrc --------------------

----------------------- _vimhelp ---------------------
vimhelp () { vim -c "help $1" -c on -c "au! VimEnter *" }
gvimhelp () { gvim -c "help $1" -c on -c "au! VimEnter *" }
---------------------- / .zshrc --------------------

I was once thinking like
   vim -c "h<TAB>
=> vim -c "help
=> vim -c "help Z<TAB>
=> vim -c "help ZZ"
but then I just wrote my little vimhelp wrapper which was easier
to do...

Ciao,
Thomas

-- 
 Thomas Köhler       Email:       jean-luc@xxxxxxxxxxxxxxxxx
     <><             WWW:              http://gott-gehabt.de
                     IRC:                           tkoehler
                     PGP public key available from Homepage!

Attachment: signature.asc
Description: Digital signature



Messages sorted by: Reverse Date, Date, Thread, Author