On Wed, May 13, 2015 at 4:17 PM, Paul <[email protected]> wrote:

> My local laptop monitor is....shall we say, "different" from an external
> monitor.  I find that I have to adjust the screen colours.  However, I
> switch between the native monitor and an external monitor a lot.  In vim,
> is there a way to check whether the monitor os the local one or not?  I can
> then use that conditional test to set the appropriate colour.
>

If you "extend" your monitor, then you can use the window position to check.

I extend mine above my existing monitor (instead of beside it).
These functions report negative values for me when I move it to the
extended monitor.

getwinposx() < 0
getwinposy() < 0

You can simply check for a range of values.

I also wrote a mapping to toggle my Vim session back and forth between the
monitors (if this helps):


if has("gui_running")
    " Reposition gvim when using the windows extended monitor
    " Top and bottom
    " Use negative values if screen is above main desktop.
    " Basically, position Vim and look at this output:
    " echo getwinposx() getwinposy()

    " nnoremap <Leader>fx :exec 'winpos '.(getwinposx()<0 ? '15' : '-15').'
'.(getwinposy()<0 ? '17' : '-1183')<CR>
    nnoremap <Leader>fx <C-O>:exec 'winpos '.(getwinposx()<0 ? '15' :
'15').' '.(getwinposy()<0 ? '40' : '-1192')<CR>
    " This version will change the font size (since the monitor is bigger)
and move the screen.
    " Had to record the X and Y positions since set guifont= will cause the
screen to move under certain cirumstances.
    nnoremap <Leader>fx :let winx = getwinposx()\|let winy =
getwinposy()\|exec 'set guifont=Bitstream_Vera_Sans_Mono:h'.(winy<0 ? '11'
: '11').':b:cANSI'\|echomsg 'executing winpos '.(winx<0 ? '15' : '15').'
'.(winy<0 ? '40' : '-1192')\|exec 'winpos '.(winx<0 ? '15' : '15').'
'.(winy<0 ? '40' : '-1192')<CR>
    " Move Vim left and right (assuming screen configuration)
    " nnoremap <Leader>fx :exec 'winpos '.(getwinposx()<1900 ? '2055' :
'276').' 14'<CR>
    " nnoremap <Leader>fx <C-O>:exec 'winpos '.(getwinposx()<1900 ? '2055'
: '276').' 14'<CR>
endif



HTH,
David

-- 
-- 
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.

Reply via email to