Let gVim always run a single instance

后端 未结 12 696
时光说笑
时光说笑 2020-12-12 19:14

Is there a way to let gVim only run a single instance, so that when a new file is opened with it it\'s automatically opened in a new tab in the currently running instance?

12条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-12 19:38

    The solutions above don't launch the gvim server on first execution, so I use:

    ANS=`pgrep -fx "$VIM"`
    
    # Launch server if needed
    if [[ ! $ANS ]]; then
       $VIM
    fi
    
    # Now open the file
    if [[ $1 ]]; then
        $VIM --remote-tab "$@"
    fi
    

    modified from https://stackoverflow.com/a/15335004/214686

提交回复
热议问题