Christian Brabandt wrote:
Hi Linda!
Using WinEnter and VimEnter autocommands worked for me:
if !exists("g:autocommands_loaded")
let g:autocommands_loaded =1
au VimEnter,WinEnter * let ln = line("'\"") | if
search("vim=:SetNumberAndWidth",'n') | call SetNumberAndWidth() | endif
endif
----
It works great! Thanks much.
BTW, it may be of no interest to you being a gvim
list, but this is the current version of my "gvim.shh" script.
It is the reason why I ran into the problem in multiple
tabs -- as I wrote it to automatically add "-p" when I
was editing a "pair" of files (pair in this case = {cc,h}.
The script looks at the first file arg and looks to see if
it finds 2 files with the same base, "cc" and "h", so if I
have a "c++ and its include file". So assuming I have
main.cc and main.h in my current dir, then either:
gvim main
or
gvim main.
or
gvim main.cc
or
gvim main.h
and gvim will automatically open up both files in tabs.
If one only wants to open one of the above files,
they can use 'gvim -- <filename>' and the "--" will disable
the automatic adding of "-p".
I invoke the bash-script in my "~/.bashrc" with the line:
[[ $(type -t gvim) == function ]] || . ~/bin/gvim.shh
------
gvim.shh:
------
#!/bin/bash -u
#include stdalias
shopt -s expand_aliases
alias my=declare string=declare
alias sub=function array='declare -a' int='declare -i'
sub gvim () {
array orig_args=($@) gv_files=() gv_ops=()
int use_tab=0 look_for_ops=1
sub _exec_gvim() {
array args
((use_tab)) && args=("-p")
(( ${#gv_ops[@]:-0} )) && args+=(${gv_ops[@]})
(( $# )) && args+=($@)
command gvim "${args[@]}"
unset -f _exec_gvim
}
while (($#)); do
my arg="$1" ; shift
if ((look_for_ops)); then
if [[ ${arg:0:1} == '-' ]] ; then
arg=${arg:1}
[[ $arg == '-' ]] && { look_for_ops=0; continue; }
[[ $arg == 'p' ]] && { use_tab=1; continue; }
gv_ops+=("-$arg"); continue;
fi
fi
gv_files+=("$arg")
done
((!${#gv_files[@]:-0})) && { _exec_gvim; return $? ; }
if (( ${#gv_files[@]} == 1 )); then
string path=${gv_files[0]}
string pname=${path%.?(cc|h)} # then get rid of
if ((look_for_ops||use_tab)); then
[[ -f $pname.cc && -f $pname.h ]] && {
_exec_gvim "$pname".{cc,h} ; return $?; }
fi
fi
command gvim "${orig_args[@]}"
}
export -f gvim
if alias gvim >& /dev/null; then
# note -- need to figure out what to do if we find pre-existing alias
# for now, issue warning/error
#string _gvim_alias_=$(alias gvim)
#galias=${_gvim_alias_#alias *=}
#array gwords=(${galias//\'/})
echo -e "\agvim is aliased; function will be ignored!!\a"
fi
# vim ts=2 sw=2
--
--
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
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.