Skip to content

asjafjell/intellij-for-linux-vdi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 

Repository files navigation

How to set up Virtual Linux for coding in Intellij IDEA

Purpose

The purpose of this setup is to be able to use Intellij IDEA in an Citrix Workspace with vaguely similary keyboard setup as on a Mac in order to code.

This guide is based on a setup where the hardware is a Mac with a physical Norwegian keyboard, American English as layout and the virtual device is Ubuntu 20.04. It may work on other setups.

After doing this guide it will feel like coding on a Mac. Unfortunately, not all key bindings are like the default Mac layout for Intellij IDEA. In addition, not all keys on the bottom row can be mapped correctly. Only the right Option key will act as a Command key, and only in Intellij IDEA.

Screenshot 2023-09-22 at 17 30 32

Guide

  1. Add keyboard layout English (US, intl., with dead keys) on Ubuntu.

  2. In the Preferences of Citrix Workspace (image), choose the double arrows in the right corner, Keyboard and set the following:

    image

    This will map:

    • Right ⌘ button to Meta, which we can map in Intellij IDEA to act as the Command button.
    • Left Option to Alt / Option
    • Left ⌘ to Super
  3. Map Windows key to Meta. This is a bit backwards, but it does the trick for giving us a key which can act as a Command key (⌘). In Intellij IDEA, do the following:

  • Help -> Edit Custom Properties,
  • Add keymap.windows.as.meta=true to the file.
  1. Install the plugin macOS Keymap. This plugin adds keymap called Intellij IDEA Classic (macOS) as a keymap - please change to this mapping in Keymap settings. This mapping will have a lot of shortcuts where Meta is used.

  2. We must remove a few default shortcuts from Ubuntu in order to use them in Intellij. Remove with the following script:

    # To find other settings, please install app Dconf-Redigering. Most settings are found within 
    # org.gnome.desktop.wm.keybindings some within /org/gnome/mutter/
    # Choosing a shortcut, right click and copy gives a setting like the one under here. Emptying the
    # array removes all shortcuts for that functionality
    
    # Remove shortcuts for Activities:
    gsettings set org.gnome.shell.extensions.dash-to-dock hot-keys false
    for i in $(seq 1 9); do gsettings set org.gnome.shell.keybindings switch-to-application-${i} '[]'; done
    
    # Remove Show Programs and Run Command:
    gsettings set org.gnome.desktop.wm.keybindings panel-main-menu "[]" # Disable Alt + F1
    gsettings set org.gnome.desktop.wm.keybindings panel-run-dialog "[]" # Disable Alt + F2
    
    # Remove showe/hide desktop (cmd + D) - enables duplicating lines
    gsettings set org.gnome.desktop.wm.keybindings show-desktop "[]"
    
    # Remove move window to left and right part of screen
    gsettings set org.gnome.mutter.keybindings toggle-tiled-left "[]"
    gsettings set org.gnome.mutter.keybindings toggle-tiled-right "[]"
    
    # Remove resizing shortcuts Alt + F7 / F8
    gsettings set org.gnome.desktop.wm.keybindings begin-resize "[]"
    gsettings set org.gnome.desktop.wm.keybindings begin-move "[]"
    
    # Disable right click window menu - to enable Quick definition / peek
    gsettings set org.gnome.desktop.wm.keybindings activate-window-menu "[]"
    
    # Disable CMD + P shortcut for monitor switching
    gsettings set org.gnome.mutter.keybindings switch-monitor "[]"    
    
    # Disable single press on left command button to open window switcher
    gsettings set org.gnome.mutter overlay-key '' 
  3. Disable notification-shortcut. In Ubuntu settings, go to Tastatursnarveier, and remove shortcut Vis varslingsliste.

  4. Disable vis oversikt-shortcut. In Ubuntu settings, go to Tastatursnarveier, and remove shortcut Vis oversikt. Then remove one frome GUI so that we can select all text in a file: Innstillinger -> Tastatursnarveier -> Vis alle programmer : Disable

  5. Install Frame switcher which enables hot swapping between multiple instances of Intellij IDEA. Enables opening recent projects and open projects by search.

Keybindings to set up

There are two different ways to add the shortcuts:

  • Alternative 1: Download the Shortcuts file and add it to ~/.config/Jetbrains/<CURRENT JETBRAINS VERSION>/keymaps. Restart the IDE and choose the keymap in Settings -> Keymap. If it does not work, please see Alternative 2
  • Alternative 2: Add the shortcuts manually:
  1. Right click-menu keybinding. Add the following shortcut in Settings -> Keymap -> Show Context Menu: Meta + Shift + 0.
  2. Search for Go to, set following
    • Go to class in Go to by Name Actions: Ctrl + O
    • Go to file in Go to by Name Actions : Ctrl + Shift + O
  3. Search for Move statement, set following
    • Move statement up: Ctrl + Shift + Up
    • Move statement down: Ctrl + Shift + Down
  4. Disable shortcuts for apps/mission control Ctrl + Up and Ctrl + Down on the Mac host to enable next/previous method:
    • System settings -> Keyboard -> Keyboard Shortcuts -> Mission Control
    • Untick Mission Control and Application Windows
  5. Disable shortcut for Spotlight -> Show Finder search window on the Mac host. On your mac, go to System Settings -> Keyboard -> Keyboard Shortcuts, go to Spotlight and disable Show Finder search window.
  6. Change shortcut Find in files to Meta + Shift + F
  7. Change shortcut Replace in files to Meta + Shift + R
  8. Change shortcut Close tab in Editor close actions to Meta + W
  9. Change shortcut Delete line in Editor Actions to Meta + Backspace
  10. Change shortcut Show usages to Ctrl + Option + F7 (Remember Option is as described in picture above)
  11. Change shortcut Debug in Run/Debug to Ctrl + D
  12. Change shortcut Debug context configuration to Ctrl + Shift + D
  13. Change shortcut Run in Run/Debug to Ctrl + R
  14. Change shortcut Run context configuration to Ctrl + Shift + R
  15. Change shortcut Quick documentation to F1
  16. Change shortcut Left in Navigate to Meta + Ctrl + Left
  17. Change shortcut Right in Navigate to Meta + Ctrl + Right
  18. Add shortcut Comment with line comment to Meta + Minus or Meta + /
  19. Change shortcut Quick definition to Option + Space (Peek)
  20. Change shortcut Run in Main menu - Run to Ctrl + Option + R
  21. Change shortcut Debug in Main menu - Debug to Ctrl + Option + D
  22. Change shortcut Resume Program to Cmd + Option + R
  23. Change shortcut Select next tab to Cmd + Shift + Right (Choose keep the other places it is used)
  24. Change shortcut Select previous tab to Cmd + Shift + Left (Choose keep the other places it is used)
  25. Change Shortcut Extend Selection in Editor ActionstoAlt + Up`
  26. Change Shortcut Shrink Selection in Editor ActionstoAlt + Down`

Summary of nifty shortcuts after configuration

  • Start/end of line: fn + Left / Right or Cmd + Left / Right
  • Page up/down: fn + Up / Down
  • Selection for next occurence, Select/unselect: Ctrl + G / Ctrl + Shift + G
  • Method, Next/Previous: Ctrl + Up/Down
  • Move method up/down: Ctrl + Shift + Up/Down
  • Error, Next/Previous:F2 / Shift + F2
  • Selection, Increase/Decrease: Alt + Up / Alt Down
  • Find in files: Meta + Shift + F
  • Replace in files: Meta + Shift + R
  • Close tab: Meta + W
  • Delete line: Meta + Backspace
  • Open scratch file: Ctrl + Shift + N
  • Show usages to Ctrl + Option + F7
  • Debug previous run: Ctrl + D
  • Debug in current context: Ctrl + Shift + D
  • Toggle line breakpoint: CMD + F8
  • Evaluate expression: Alt + F8
  • Quick evaluate expression: Cmd + Alt + F8
  • Quick documentation: F1
  • Run by showing the Run-configuration menu: Ctrl + Option + R
  • Debug by showing the Debug-configuration menu: Ctrl + Option + D
  • Resume Program: Cmd + Option + R
  • Select next/previous tab: Cmd + Shift + Right/Left

When things go wrong

App menu is hidden

  • Install and start Gnome tweaks
    sudo apt install gnome-tweaks
    gnome-tweaks
  • Choose Utvidelser
  • Activate with slider switch in the top.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •