Inserting text with a keyboard shortcuts in Ubuntu

7,421

Solution 1

You can hit Ctrl+Shift+U, type an Unicode code point and hit Enter to insert the character bound to that Unicode code point;

For example, to insert :

  • Hit Ctrl+Shift+U
  • Type 2b50
  • Hit Enter

I suggest you to keep using this method, as most Ctrl+[...], Alt+[...] and Shift+[...] sequence will end up conflicting with other functions; however if you really want to use a custom shortcut, you can try your luck and bind a custom shortcut to an xdotoolcommand in System Settings > Keyboard > Shortcuts > Custom Shortcuts; for example, the xdotool command to insert would be:

xdotool key --window '$(xdotool getactivewindow)' Ctrl+Shift+U2B50

Solution 2

Alternatively you can enable compose keys to create these symbols or even strings of text with ease without remembering these annoying keyboard number-letter combinations.

Open GEdit and insert the following:

include "/usr/share/X11/locale/en_US.UTF-8/Compose"

<Multi_key>     <1>     <2>     <3> : "Your text"   # Quick description
<Multi_key>     <s>     <t>     <a> : "⭐"  U2B50    # Star Symbol

Save this as .XCompose (case sensitive) in your home directory.

Open your keyboard settings (system settings → keyboard settings) and go to the shortcuts tab. Under the "typing" section you'll find a "Compose Key" setting. Set this to your compose key (I advice right alt)

Gnome Compose Key setting for gnome
Unity Compose Key setting for Unity Xfce
Compose Key setting for xfce. Source: wikipedia Compose Key

Log out and log back in.
To quickly summon your text press the following keys in sequence Compose Key123.
Just replace 1,2,3,4,5 etc etc with whatever keys you want to use.

If it isn't working add

export GTK_IM_MODULE="xim"

to the end of ~/.profile. If xim isn't working for you you'll have have to install uim (sudo apt-get install uim) and replace the xim in ~/.profile with uim and logout and log back in.

Solution 3

I have configured AutoKey to insert the

For example, to insert :

  • Hit Ctrl+Shift+U
  • Type 2b50
  • Hit Enter

enter image description here

to install AutoKey read:

https://askubuntu.com/a/799654/110556

List of unicodes:

https://en.wikipedia.org/wiki/List_of_Unicode_characters#Currency_Symbols https://en.wikipedia.org/wiki/Star_%28glyph%29

Share:
7,421

Related videos on Youtube

mtszkw
Author by

mtszkw

Updated on September 18, 2022

Comments

  • mtszkw
    mtszkw over 1 year

    I know we can insert some unicode characters by pressing ALT+[code] combination under Windows, right? I would like to have a similar option under Ubuntu, however in addition to that I'd need to choose my shortcut keys and text to be inserted. For example, I want to insert "⭐" character with a combination (it doesn't matter what combination, it may be even ALT + SHIFT + CTRL + 123).

    Is this even possible?

  • Akisame
    Akisame over 8 years
    I would just use compose keys for this. Much cleaner and quite a bit easier. Wait, I'll write an answer for other people who want to do this.
  • kos
    kos over 8 years
    Does this work outside GNOME? Or, mainly, does this work in Unity? if it does, hats off.
  • Akisame
    Akisame over 8 years
    Yes, this works outside of GNOME. In fact, it works as long as you are using the X Window System.
  • Akisame
    Akisame over 8 years
  • Akisame
    Akisame over 8 years
    or you can use the terminal with the following command to enable compose keys: $ dconf write /org/gnome/desktop/input-sources/xkb-options "['compose:{key}']" where {key} is your chosen key-name (e.g. "['compose:ralt']" would make right alt your compose key.