"Vim other than Vim" for Vim light users

What you can do after seeing this article

Who is the target of this article

Those who have stepped into the world of Vim halfway and are in the following situations

A guy for those who want to try it for the time being

① Clone this repository to a suitable location

[If you get lost, this] Enter the following on the terminal

$ cd && git clone https://github.com/mojamozya/allapps-vimlike.git

② Add the following to bashrc etc.

[If you get lost, this]

$ echo 'xkbcomp -I$HOME/allapps-vimlike/.xkb ~/allapps-vimlike/.xkb/keymap/mykbd $DISPLAY 2> /dev/null' >> ~/.bashrc

For now, anyone who writes Simply mapped (Mapped with XKB) in the repository will be able to do it.

If you have not set the terminal to start up at startup, please start up the terminal every time you start up.

③ Install Autokey

$ sudo apt install autokey-gtk

If you're not Gnome, maybe autokey-qt

④ Open the autokey screen

$ autokey

⑤ Enable the downloaded repository with Autokey

Due to the specifications of Autokey, this is a bit confusing. For the time being, you can delete all the folders and phrases that are included in autokey by default.

On the Autokey screen, select File-> New-> Folder from the menu bar, and then Select ʻUse Default and create a folder called general in the default location. There should be a folder called general in ~ / .config / autokey / data, so Make a symlink there ʻallapps-vimlike / .autokey / general / vimlike.

[If you get lost, this] After creating a folder called general in the default location as described above from the Autokey screen,

$ ln -s ~/allapps-vimlike/.autokey/general/vimlike ~/.config/autokey/data/general

⑥ If there is no problem after checking the operation, start autokey at startup.

For ubuntu, you can just add it to session, People from other distributions should check it out for themselves.

You may add ʻautokey` to bashrc, but It may be a bit dull that autokey is restarted every time the terminal starts up

How to use

Can be used.

Since the conversion key maps to the Hyper key, Read the key mapping as Hyper = Transform.

You can probably see how to make Hyper other than the conversion key by looking at the atmosphere of the source around xkb. If there is demand, I will write a specific method, but I will omit it because it is sober and troublesome.

Keymap introduction and supplement

(A simple keymap is also written in the repository)

Simple guy

Like Vim, the cursor is hjkl. In other words, if you press the conversion key and hjkl at the same time, they will become cursor keys.

Esc also shakes Ctrl + [ and Ctrl + @ as a countermeasure when the little finger does not reach. (I often mistakenly press [and @)

The point is that BackSpace and Delete are assigned to ; and : respectively. I don't hear as much deletion as the original Vim, so By pressing; to delete it, it's not like Vim, but it's a normally useful shortcut. (Just hitting; with your little finger will make you tired, so it may be good to set backspace around i.)

: Well, that's the feeling, "If you press the right side of Backspace, the right side of the cursor disappears." If you feel like Vim, press x. I think it doesn't matter which one.

It also features a and e with Emacs-like key bindings. For convenience of pressing the conversion key at the same time There is some stress when you press ^, When you press Shift + $ It is as stressful as when a smoker has not smoked for 3 hours.

So, I tried to use Emac key binding here.

Pushed keys Mapped Keys Like Usage
Hyper + h Vim Cursor key
Hyper + j Vim Cursor key
Hyper + k Vim Cursor key
Hyper + l Vim Cursor key
Hyper + ; BackSpace Original Backspace
Hyper + x BackSpace Original Backspace
Hyper + : Delete Original Delete
Hyper + a Home Emacs Move cursor to the head of line
Hyper + e End Emacs Move cursor to the end of line
Hyper + m Enter Emacs Enter key
Hyper + Ctrl + [ Esc Vim Esc (Mapped with AutoKey)
Hyper + Ctrl + @ Esc Vim Esc (Mapped with AutoKey)

The one who moves the cursor like a macro

From here on, I'm doing something a little complicated. {Ctrl + cursor key moves the cursor in a nice way, IME function? OS function? I don't know that, but it behaves a bit like Vim's ʻe or b.

But I'm using ʻein Emacs binding, so I assignedCtrl + →tow, which behaves like ʻe.

Ctrl + → is more like ʻe, though. But after all, the details are different from ʻe, so it doesn't matter which one.

Similarly, Ctrl + ← is assigned to b.

Also, like ʻo. By setting a macro that moves to the end of the line with the End key and then presses the Enter key It reproduces Vim's ʻo in a pseudo manner.

How to reproduce Shift + o is difficult. If you want to make the IDE indentation look good, just leave it as it is. If you want it to work even when you're on the top line, maybe Home-> Enter-> ↑?

Pushed keys Mapped Keys Like Usage
Hyper + Shift + b Ctrl + ← Vim Move cursor to the head of word
Hyper + Shift + w Ctrl + Shift + → Vim Secelt the range from current cursor to the head of word
Hyper + w Ctrl + → Vim Move cursor to the end of word
Hyper + Shift + w Ctrl + Shift + → Vim Secelt the range from current cursor to the end of word
Hyper + o End -> Enter Vim Make a line below current cursor
Hyper + Shift + o ↑ -> End -> Enter Vim Make a line above current cursor

Shortcut (Mapped with Autokey) The rest is a shortcut. Personally, Ctrl + x, Ctrl + c, and Ctrl + v are next to each other. I don't really like it. If you want to copy it, paste it and you're done! I'll do it! It will get better. So, I'm swinging to d, y, p, and so on.

Since it was difficult to reproduce dd and yy, I made the hotkeys Ctrl + d and Ctrl + y.

Then, you can go back to the beginning of the line with a and delete (yank) with Shift + d (y), so it's okay. Is it like Ctrl + a-> Ctrl + k in Emacs? I don't know because I'm not familiar with Emacs.

I also don't like Ctrl + z because it makes my fingers cramped when I press it. I don't like Redo with Ctrl + Shift + z because of the risk of pressing it incorrectly. So I reproduced it with ʻuandCtrl * r`.

Pushed keys Mapped Keys Like Usage
Hyper + u Ctrl + z Vim Undo
Hyper + Ctrl + r Ctrl + Shift + z Vim Redo
Hyper + y Ctrl + c Vim Copy
Hyper + Ctrl + d Home -> Shift + End -> Ctrl + c -> ← Vim Cut
Hyper + Shift + y Ctrl + End -> Ctrl + c -> → Vim Copy the range from current cursor to the end of line
Hyper + d Ctrl + x Vim Cut
Hyper + Ctrl + d Home -> Shift + End -> Ctrl + x -> Delete Vim Cut
Hyper + Shift + d Ctrl + Shift + End -> Ctrl + x Vim Cut the range from current cursor to the end of line
Hyper + p Ctrl + v Vim Paste

to use vscode

When using with vscode, I think it's a good idea to set Keyboard: Dispatch to keyCode. This may make some shortcuts in vscode behave erratically. In that case, if you play with the keyboard shortcuts of vscode, it will be cured.

Other

I cannot take responsibility even if the personal computer is broken due to something TT If you have any questions, please.

Recommended Posts

"Vim other than Vim" for Vim light users
Modern Python for intermediate users
BigQuery integration for Python users
Before the introduction to machine learning. ~ Technology required for machine learning other than machine learning ~