Shortcut for button "Resize page to drawing or selection"

Post questions on how to use or achieve an effect in Inkscape.
Ailurus
Posts: 115
Joined: Fri Oct 22, 2010 9:53 am
Location: The Netherlands
Contact:

Shortcut for button "Resize page to drawing or selection"

Postby Ailurus » Thu May 10, 2012 1:16 am

Very short question, is there a shortcut for the button "Resize page to drawing or selection" (accessible from File → Document Properties, and then click the arrow in front of "Resize page to content...")?

chriswww
Posts: 383
Joined: Fri Nov 19, 2010 3:04 pm

Re: Shortcut for button "Resize page to drawing or selection

Postby chriswww » Thu May 10, 2012 1:30 pm

it's not in the keys reference afaik.
customizing toolbars has been on the radar for quite a while..wonder if it's not too far on the horizon.

v1nce
Posts: 696
Joined: Wed Jan 13, 2010 4:36 am

Re: Shortcut for button "Resize page to drawing or selection

Postby v1nce » Thu May 10, 2012 10:31 pm

Do we really need a shortcut for every action ?
I never used this function and if I got to use it, I think I'll need it only once (before saving), don't I ?

Do you process batch of files to need this shortcut ?

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Shortcut for button "Resize page to drawing or selection

Postby ~suv » Thu May 10, 2012 11:55 pm

Ailurus wrote:Very short question, is there a shortcut for the button "Resize page to drawing or selection" (accessible from File → Document Properties, and then click the arrow in front of "Resize page to content...")?

The verb already exist:

Code: Select all

$ inkscape --verb-list | grep FitCanvas
FitCanvasToSelection: Fit the page to the current selection
FitCanvasToDrawing: Fit the page to the drawing
FitCanvasToSelectionOrDrawing: Fit the page to the current selection or the drawing if there is no selection

You only have to add a keymapping for it (Inkscape doesn't ship with predefined keyboard shortcuts for each available verb). Save the following code

Code: Select all

<?xml version="1.0"?>

<keys name="Inkscape default">

  <!-- Fit the page to the current selection -->
  <bind action="FitCanvasToSelection" />

  <!-- Fit the page to the drawing -->
  <bind action="FitCanvasToDrawing" />

  <!-- Fit the page to the current selection or the drawing if there is no selection -->
  <bind key="F" modifiers="Ctrl,Alt,Shift" action="FitCanvasToSelectionOrDrawing" />

</keys>
as 'default.xml' in the 'keys' sub-directory of your Inkscape preferences profile [1], adjust key and modifiers as needed and restart Inkscape.


[1] The location depends on your platform:
on linux/osx:

Code: Select all

~/.config/inkscape/keys/default.xml
on Windows:

Code: Select all

%APPDATA%\inkscape\keys\default.xml

Ailurus
Posts: 115
Joined: Fri Oct 22, 2010 9:53 am
Location: The Netherlands
Contact:

Re: Shortcut for button "Resize page to drawing or selection

Postby Ailurus » Fri May 11, 2012 2:21 am

Very helpful, thanks! For future purposes, is there any way to see whether a specific keyboard shortcut is already in use?

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Shortcut for button "Resize page to drawing or selection

Postby ~suv » Fri May 11, 2012 5:00 am

Ailurus wrote:Very helpful, thanks! For future purposes, is there any way to see whether a specific keyboard shortcut is already in use?

Inkscape doesn't create a (dynamic) list of keyboard shortcuts in-use - when launching, it loads and parses key-mapping files from two locations: the shared one which gets installed with Inkscape (same for all users), and the one from the current user inkscape profile (if present). Shortcuts redefined in the user key-mapping file will override those in the shared file.

Your best bet to find free key/modifier combinations is to search in the shared file:
  • on linux, usually

    Code: Select all

    /usr/share/inkscape/keys/default.xml
  • on OS X, it's inside the application bundle:

    Code: Select all

    /Applications/Inkscape.app/Contents/Resources/keys/default.xml
  • on Windows, the shared resources are installed into the program folder Inkscape was installed to.

You can also consult the online keyboard and mouse reference, or browse the files in the the source code repositories ( development branch / 0.48.x branch ).


Return to “Help with using Inkscape”