我主要在 gvim 和许多终端上工作。最初,我更喜欢在单个 vim 实例中打开所有文件。为此,我使用别名从当前“vim 服务器”中的终端打开文件。
alias rv="gvim --remote-silent"
Run Code Online (Sandbox Code Playgroud)
但是在单个 vim 实例中打开来自多个项目的许多文件会影响我的工作效率,因此我将别名升级为一个函数。
# main function
rv() {
local args options server
options=$(getopt -o hils:t: -l "help,info,list,set:,target:" -- "$@")
if [[ $? -ne 0 ]]; then
echo "Failed to parse options."
return 1
fi
# a little magic, necessary when using getopt
eval set -- "$options"
# go through the options with a case and use shift to analyze one option at a time.
while true; do
case "$1" in
-h|--help) …Run Code Online (Sandbox Code Playgroud)