With our latest update (Xshell Build 0940/Xmanager Enterprise Build 0922) you can now map keys to certain session property options to quickly make necessary changes on-the-fly. These options are:
- enabling “Use ALT key as Meta key”
- switching between Unicode/Non-Unicode
- enabling “Scroll to the bottom when terminal input/output.”
Let’s try setting a custom mapped key to enable “Use ALT key as Meta key” while utilizing Emacs within Xshell. Emacs users know that the meta key is important for navigation, editing, etc. within Emacs. Without the meta key set to ALT, Windows will “steal” the ALT key and send the keyboard focus to the menubar of Xshell.
First, let’s map a key to the “Use ALT key as Meta key” option. Navigate to your custom key mappings by going to Tools -> Options -> Keyboard and Mouse -> Edit. Create a new custom key mapping using your desired key combination. For this example, I will be using Ctrl+Shift+m and setting it to “[Terminal] Use Alt as Meta Key.”
(Note: Do not use any ALT key combinations or you won’t be able to use they key combination to disable the “Use ALT key as Meta key” option once it’s been enabled.)
Now let’s get back to our terminal window in Xshell and open Emacs. We’ll type a short phrase to demonstrate Meta Key usage.
Looks like we made a mistake. There are two “the”s in the sentence. We’ll need to go back and delete one of them. In Emacs there are several ways to accomplish this. For this example, we’ll move back three words, delete the extra “the,” and move back to the end of the line to continue typing.
But without the “Use ALT key as Meta key” option enabled, you cannot accomplish this as hitting ALT moves keyboard focus to the File menu. Normally, you’d need to navigate to session properties and check the appropriate box, but since we’ve created a custom key mapping, we can do it on-the-fly! Hit Ctrl+Shift+m and start manipulating text immediately.
With the Meta key enabled I was able to navigate backwards three words (M-b), delete backwards one word (M-Backspace), and navigate forwards to the end of the line (C-e).
You can use the other two key mapping options, “Switch encoding to Unicode” and “Scroll Bottom on Input/Output,” in a similar fashion. Once mapped to a key, the key essentially becomes a toggle for switching between enabled and disabled.