Loading ...
Sorry, an error occurred while loading the content.

RE: Window Size in gVim

Expand Messages
  • David Fishburn
    Steve, I am pretty sure I can make good use of these functions, thank you. I have also updated them. I often name my gvim sessions, so that I open related
    Message 1 of 5 , Oct 31, 2003
    • 0 Attachment
      Steve,

      I am pretty sure I can make good use of these functions, thank you.

      I have also updated them.

      I often name my gvim sessions, so that I open related files in 1 vim (ie
      all the files for one project, or newsgroup postings, or email, ...).

      So I wanted to be able to store / recall the position of the gvim window
      based on the NAME of the gvim session.
      For people already using these functions they should see no difference
      (except if they use multiple gvims.

      These modified versions work this way.
      Also instead of hard coding defaults, I let the defaults be the current
      &lines and &columns.

      *******************
      " Courtesy of Steve Hall [ digitect@... ]
      function! Screen_init()
      " - Remembers and restores winposition, columns and lines stored in
      " global variables written to viminfo
      " - Must follow font settings so that columns and lines are accurate
      " based on font size.

      " initialize
      if !exists("g:COLS_".v:servername)
      let g:COLS_{v:servername} = &columns
      endif
      if !exists("g:LINES_".v:servername)
      let g:LINES_{v:servername} = &lines
      endif
      if !exists("g:WINPOSX_".v:servername)
      " don't set to 0, let window manager decide
      let g:WINPOSX_{v:servername} = ""
      endif
      if !exists("g:WINPOSY_".v:servername)
      " don't set to 0, let window manager decide
      let g:WINPOSY_{v:servername} = ""
      endif

      " set
      execute "set columns=".g:COLS_{v:servername}
      execute "set lines=".g:LINES_{v:servername}
      execute "winpos ".g:WINPOSX_{v:servername}."
      ".g:WINPOSY_{v:servername}

      endfunction

      function! Screen_get()
      " used on exit to retain window position and size

      let g:COLS_{v:servername} = &columns
      let g:LINES_{v:servername} = &lines

      let g:WINPOSX_{v:servername} = getwinposx()
      " filter negative error condition
      if g:WINPOSX_{v:servername} < 0
      let g:WINPOSX_{v:servername} = 0
      endif

      let g:WINPOSY_{v:servername} = getwinposy()
      " filter negative error condition
      if g:WINPOSY_{v:servername} < 0
      let g:WINPOSY_{v:servername} = 0
      endif

      endfunction

      " autocmd VimEnter * breakadd func Screen_init
      autocmd VimEnter * call Screen_init()
      autocmd VimLeavePre * call Screen_get()
      ******************


      Dave
    Your message has been successfully submitted and would be delivered to recipients shortly.