joppot

コピペで絶対動く。説明を妥協しない

ソフトウェア

In emacs on iTerm2, resolve you can’t enter symbol key binding such as C-; C-: C-> C-< C-. C-,

投稿日:

Pocket

Abstract

Hello eveyone it’s me candle.
This time I will show you how to solve the problem that you can’t use symbol keybind on your iTerm2 emacs.
Basically, emacs on iTerm2 can’t use key binding of control + symbol.
The detail thing is written in this article.

(japanese)
http://memo.sugyan.com/entry/20120224/1330051378

Acouding to the article
Apparently it seems that the range of ASCII that ctrl key can control is decided.

This post referred to the below linked article.
I tried how to setup symbol key binding a few years ago and I was frustrated.
But I solved it by that. it was really helpful.

(japanese)
http://d.akinori.org/2012/01/02/


Precondition

You use emacs
You use iTerm2



Setting policy

First of all, I wrote it in the abstract chapter, iTerm2 can’t use control + symbol key binding directly.
So we use the function of emacs as if we hit the control + symbol.

Since I don’t know about detail thing of emacs, I quoted from the referenced article.

(I translated to English)

Actually Emacs has a gimmick function called “event-apply-*-modifier” which is equivalent to the sticky modifier key.
For example, pressing C-x @ c (event-apply-control-modifier) and pressing RET is equivalent to pressing C-RET.

We use this function.
For example, if you want to realize “C-.” , like this “C-x @ c .”.
If you try to run “C-x @ c.” on your emacs, the same action as “C -.” will be executed.
Of course if that key binding is set.

Next, use the global shortcut key of iTerm2’s function.
When you hit “C-.” in iTerm2, if you make it to send “C-x @ c .” to emacs, you can use the “C-.” key binding in emacs.



Key setting of iTerm2

Start iTerm2 and select “Preferences…” from “iTerm2” of the top menu.
Choose the “Keys”, push the + button

We’ll try to add “C-.”

Type the “control + .” in “keyboard shortcut” field which state is active. After typing it will be displayed as “^.”

Next select “Send Hex Code” from the pull down menu.
Write the below text in the appeared text field.

18 40 63 2e

This Hex code corresponds to these.

18 = C-x
40 = @
63 = c
2e = .

In brief, that is

C-x @ c .

Push the ok button.
The other key bindings are these.

ショートカットキーHex code
C-,18 40 63 2c
C-.18 40 63 2e
C-:18 40 63 3a
C-;18 40 63 3b
C-<18 40 63 3c
C->18 40 63 3e

I want you to be careful.

“C-<" is Control + Shift + <

“C->” is registered with Control + Shift + >

As you can see from the above image, the only difference is the last hex code.
If you want to assign C-( or C-/ etc, please see hex code from the below site.

http://www9.plala.or.jp/sgwr-t/c_sub/ascii.html

iTerm2 setting is finish.

Bind a key in emacs

We will assign C-.
We create a function to display the path of the file and assign it to shortcut.
Open the emacs configuration file.

emacs .emacs.d/init.el

Write this.

(defun show-file-name ()
  "Show the full path file name in the minibuffer."
  (interactive)
  (message (buffer-file-name)))

(global-set-key (kbd "C-.") 'show-file-name)

Save it and reload the file.

M-x eval-buffer

And execute C-.

C-.

The file name will be displayed in the bottom.

This means that “C-.” entered on the keyboard has been converted to “C-x @ c .” with iTerm2 and that keybinding worked well on emacs.

It works good.

Conclusion

You can define more shortcut keys with simple symbol key bindings.

スポンサードリンク

If you think this article is good, share it please

-ソフトウェア
-,

執筆者:


comment

Your email address will not be published. Required fields are marked *

関連記事

Connect to host mysql from docker container of “docker for Mac”

Abstract Hello everyone it’s me candle. In this post I will show you how to connect to the host mysql from the docker container of mac. For example, you may connect to mysql when running rails, wordpress etc on docker. You may prepare docker of mysql, but it can’t hold data, it is troublesome such as startup time. Then I think that it is very useful if docker can access to the host mysql. Precondition You use docker for mac

How to add extension to Ungoogled chromium

English 日本語 Abstract Hello everybody, It’s candle. I don’t use Google Chrome so much because I am firefox user, but sometimes I need to use Chrome for extensions. Google Chrome is slow, and there are some personal information protection is loose. Detail is here. https://github.com/Eloston/ungoogled-chromium So, I use ungoogled chromium. The problem of ungoogle chromium is that is not easy to install extensions. In this article, I’ll show you how to install plugins. This article is according to the under link. https://github.com/Eloston/ungoogled-chromium/blob/master/FAQ.md Premise Ungoogled chromium has been installed

Build flycheck + eslint environment supporting to react + es6 in Emacs.

Abstract Hello everyone it’s me candle. In this time let’s build emacs + eslint. There are many other syntax check packages such as jsHint, jsxHint, etc which check the coding rule of javascript. According to web info, these packages seem to be unable to adapt well with the latest javascript writing format such as React and es6. Nowadays eslint became to be mainstream. It has become used not only in emacs but also everywhere. I’m also emacs user, try it! I’m not a node JS and Elisp professional, it may contains useless writing or wrong writing. Please go easy on …

Import React components using Emacs and import-js2.2.0

Abstract Hello everybody it’s me candle. In this time we will import the component path with emacs and import-js. React recommends to write one component in one file, when development becomes to be big, the number of component increase. If you use 10 components with one Container, you need to write 10 import statements. import-js helps us from such troublesome work. Caution It worked well on the react web but in react native import-js didn’t successfully find out the component. Probably I think that there are some lack of the setting of import-js. Precondition Already exist React web environment I …

Using vc to manage git on emacs25

Abstract Hello everyone it’s me candle. In this article we would like to use vc(version controll) which is included by deault in emacs. It seems that vc supports to both subversion and git, not git-specific functions. If you want to use git with emacs in earnest, I recommend magit. On the other hand, since vc is installed in by default, it is good for user who want to use it easily. Precondition You use emacs You have a basic git skill. vc-git configuration of emacs Although vc supports to git, ‘git add’ and ‘git reset HEAD’ do not exist. I …

Profile


I work in the venture company as a CTO. I start to write program in University, first I learned java, C++ and PHP. In the company, I'm developing web services by Rails. I do like to automation.

スポンサードリンク

Archives