Add 'Open with VS Code' to Thunar Right-Click Menu in Xfce
If you’re using the Xfce desktop environment with the Thunar file manager, you can improve your workflow by adding custom right-click actions to open folders directly in your favorite editors like Visual Studio Code and Cursor.
This guide explains how to do that — and what %f
really means in Thunar’s custom actions.
✅ What Does %f
Mean?
When creating a custom action in Thunar, placeholders like %f
are used to refer to the selected item. Here’s what they mean:
%f
: The first selected file or folder, with full path.%F
: All selected files or folders, space-separated.%d
: The directory containing the selected item.%n
: The name of the selected item (without path).
For example, if you select a folder named ~/Projects/site/
, the command:
1
code %f
…will be executed as:
1
code /home/yourname/Projects/site/
This is perfect for opening entire folders in code editors.
✅ Add ‘Open with VS Code’
- Open Thunar.
- Go to
Edit → Configure custom actions...
- Click + to add a new action.
Basic Tab:
- Name: Open with VS Code
- Command:
code %f
- (Optional) Icon path:
/usr/share/pixmaps/code.png
or use the default VS Code icon
Appearance Conditions Tab:
- Leave File Pattern empty
- Check: ✅ Directories
✅ Add ‘Open with Cursor’
If you’re using Cursor — an AI-enhanced code editor based on VS Code — you can add a similar custom action:
Basic Tab:
- Name: Open with Cursor
- Command:
cursor %f
- (Make sure the
cursor
command is available in your terminal PATH)
Appearance Conditions:
-
✅ Directories
-
💡 If you want the “Open with VS Code” option to appear for both files and folders, enable both “Directories” and “Other Files” in the Appearance Conditions tab.
💡 Bonus: Open Multiple Files with %F
If you want to allow opening multiple selected files or folders, just change the command to use %F
instead of %f
:
1
code %F
This will open everything you selected in a single VS Code window.