sponsor Vim development Vim logo Vim Book Ad

restart.vim : Restart your gVim

 script karma  Rating 36/14, Downloaded by 2529  Comments, bugs, improvements  Vim wiki

created by
script type
          If modified buffer(s) exist, gVim won't restart.
          If you want to quit anyway, add bang(:Restart!).

  Global Variables:
      g:restart_command (default: 'Restart')
          command name to restart gVim.

      g:restart_save_window_values (default: 1)
          Save window values when restarting gVim.
          Saving values are as follows:
          - &line
          - &columns
          - gVim window position (getwinposx(), getwinposy())
          Before v0.0.1, restart.vim saves above values.
          So this variable is for compatibility.

      g:restart_save_fn (default: g:restart_save_fn is true: ['s:save_window_values'], false: [])
          This variable saves functions returning ex command.
          e.g., in your .vimrc:

              function! Hello()
                  return 'echomsg "hello"'
              let g:restart_save_fn = [function('Hello')]

          This meaningless example shows "hello" in new starting up gVim.
          When g:restart_save_window_values is true,
          this variable is ['s:save_window_values'].

              function! s:save_window_values()
                  return join([
                  \       printf('set lines=%d', &lines),
                  \       printf('set columns=%d', &columns),
                  \       printf('winpos %s %s', getwinposx(), getwinposy()),
                  \   ],
                  \   ' | '

         As you can see, this function saves current gVim's:
         - &line
         - &columns
         - getwinposx()
         - getwinposy()

      g:restart_vim_progname (default: "gvim")
         gVim program name to restart.

         Under MS Windows, you must not assign .bat file path
         to this variable. Because cmd.exe appears and won't close.

      g:restart_sessionoptions (default: "")
         If this variable is not empty, make a session from this value.
         And restore the session after vim restarts.

  - Support terminal vim
  - Support MacVim
      - MacVim support was implemented by ujihisa.
      But g:restart_sessionoptions is not recognized.
install details

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
restart.zip 0.0.8 2011-12-01 7.0 tyru - Add |restart-tips|.
- Improve error handling while restarting
restart.zip 0.0.7 2011-03-03 7.0 tyru - separate doc to doc/restart.txt
- add g:restart_cd option (thanks thinca).
- fix minor bug.
restart.zip 0.0.6 2010-12-27 7.0 tyru - Fix error when switching to GUI using :gui
- Fix warning: Delete all buffers before starting new Vim
to not show a warning about swap file. thanks thinca.
restart.zip 0.0.5a 2010-12-04 7.0 tyru GUI MacVim support (not complete). thanks ujihisa.
restart.zip 0.0.4 2010-11-27 7.0 tyru Add g:restart_sessionoptions. thanks thinca.
restart.zip 0.0.3 2010-06-26 7.0 tyru - Add g:restart_vim_progname.
- Support MS Windows.
- Fix minor bugs.
restart.vim 0.0.2 2010-05-02 7.0 tyru - Don't show 'modified buffer(s) ...' when banged.
- Add g:restart_save_window_values, g:restart_save_fn.
restart.zip 0.0.1 2010-03-02 7.0 tyru - Do not restart if modified buffer(s) exist.
- etc.
restart.vim 0.0.0 2010-01-01 7.0 tyru Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.