Vim Tips Wiki
Explore
Main Page
All Pages
Community
Interactive Maps
Community portal
To do
FANDOM
Fan Central
BETA
Games
Anime
Movies
TV
Video
Wikis
Explore Wikis
Community Central
Start a Wiki
Don't have an account?
Register
Sign In
Sign In
Register
Vim Tips Wiki
1,649
pages
Explore
Main Page
All Pages
Community
Interactive Maps
Community portal
To do
Editing
Maximize or set initial window size
Back to page
Edit
Edit source
View history
Talk (0)
Edit Page
Maximize or set initial window size
We recommend that you
log in
before editing. This will allow other users to leave you a message about your edit, and will let you track edits via your
Watchlist
.
Creating an account
is quick and free.
The edit appears to have already been undone.
Anti-spam check. Do
not
fill this in!
{{TipImported |id=88 |previous=87 |next=89 |created=2001 |complexity=basic |author=Leif Wickland |version=6.0 |rating=149/61 |category1=Windows |category2= }} ===To set the initial size of the Vim window=== Place the following in your [[vimrc]] to control the initial size of the Vim or gvim window (change the numbers to what you need): <pre> set lines=50 columns=1000 </pre> Here is a more sophisticated version: <pre> if has("gui_running") " GUI is running or is about to start. " Maximize gvim window (for an alternative on Windows, see simalt below). set lines=999 columns=999 else " This is console Vim. if exists("+lines") set lines=50 endif if exists("+columns") set columns=100 endif endif </pre> On Linux/bsd's terminal, this is done automatically. If you want to set the initial size of gvim, you can put <code>set lines=N columns=N</code> in .gvimrc. Some systems support <code>-geometry</code> as shown in the following example. {{help|-geometry}} <pre> gvim -geometry 97x46+1913+145 </pre> ===To maximize the initial gvim window using wmctrl (X server)=== Instead of running gvim directly, you can run the following simple script: <pre> #!/bin/bash exec=/usr/bin/gvim #here you can modify the location of gvim $exec -f $* & pid=$! winid="" while [ -z $winid ]; do sleep 0.05 winid=`wmctrl -pl |grep -P "^0x[0-9a-f]+[ ]+[-0-9]+[ ]+$pid" | cut -f1 -d' '` done # echo "debug: $exec started, PID=$pid, Window ID=$winid" #this maximizes the gvim window wmctrl -i -b add,maximized_vert,maximized_horz -r $winid #this switches the gvim window to fullscreen wmctrl -i -b add,fullscreen -r $winid </pre> In words, the script starts gvim, saves its process id and using wmctrl finds the window id of gvim. After that, it sends either a command for maximizing and/or for fullscreen. If you want to have this as the default whenever you call gvim, you can, e.g., save this script as /usr/local/bin/gvim . ===To maximize the initial Vim window under Windows=== On some Windows systems, pressing Win-Up (Windows key and the Up cursor key) maximizes the window, and Win-Down restores it. Put the following in your vimrc to maximize Vim on startup (from {{help|win16-maximized}}): <pre> " Use ~x on an English Windows version or ~n for French. au GUIEnter * simalt ~x </pre> To run a single session of Vim maximized use: <pre> gvim -c 'simalt ~x' </pre> A Windows alternative would be to change the properties of the shortcut to start Vim, for example: <pre> cmd /c start /max "C:\Program Files\vim\vim71\gvim.exe" </pre> This will not work, however, if you disable the menu with <code>guioptions-=m</code> and this is not usable if you need to specify gvim as configuration option of some third party tools (file managers etc). ====Using Maximize.dll plugin==== There is also a plugin with a DLL to maximize/restore the Vim window: {{script|id=1302|text=maximize.dll: Maximizing plugin for Win32 gvim}}. ====Using Nircmd==== [http://www.nirsoft.net/utils/nircmd.html Nircmd] is a small tool from Nirsoft that can be used to automate various aspects of Windows environment. You can use it to start application maximized or maximize running application window: <pre> nircmd.exe exec max "C:\Program Files (x86)\vim\vim74\gvim.exe" </pre> or as PowerShell function that accepts file argument <pre> function gvim($file) { start nircmd.exe "exec max ""C:\Program Files (x86)\vim\vim74\gvim.exe"" $file" } </pre> ===To maximize the initial Vim window under Sawfish=== You can configure [[w:c:sawfish:Main_Page|Sawfish]] to automatically maximize gvim on startup: *Run "sawfish-ui". *Select "matched windows", "Add...". *In "macthers" select "Class". *"Grab..." and click the gvim window. *Select the "Maximized" checkbox and click "OK". ==Comments== '''''TODO''''' Following are related tips. Should merge some of these. *[[VimTip427|427 Fast window resizing with plus/minus keys]] *[[VimTip488|488 Start with a wide window for diff]] *[[VimTip494|494 Maximize or restore window]] *[[VimTip507|507 Quick window resizing]] *[[VimTip669|669 Nice window resizing]] *[[VimTip883|883 Automatically maximizing gvim in KDE]] *[[VimTip1110|1110 Toggle gvim window size]] ===Edit June 9, 2014=== An edit put <code>simalt ~x</code> in the "more sophisticated" script, but that is already in the tip so I removed it. [[User:JohnBeckett|JohnBeckett]] ([[User talk:JohnBeckett|talk]]) 05:57, June 10, 2014 (UTC)
Summary:
Please note that all contributions to the Vim Tips Wiki are considered to be released under the CC-BY-SA
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Help
(
view source
)
Template:Navigation
(
view source
)
Template:Script
(
view source
)
Template:TipImported
(
view source
)
Follow on IG
TikTok
Join Fan Lab