AutoHotkey diacrictics mappings not working correctly with Vim - vim

I've been using some mappings in Vim to avoid having to switch keyboard layouts to type in diacritics in my language (Croatian). However, now I wanted to move these mappings "up" so that they're available globally. I tried using AutoHotkey for this. Here are the mappings I wrote
#CommentFlag //
!;::Send {U+010D} // č
!'::Send {U+0107} // ć
!]::Send {U+0111} // đ
![::Send {U+0161} // š
!\::Send {U+017E} // ž
These work great in every application I've tried (browsers, notepad, MS Word), but don't work in Vim, which is pretty annoying as I do most of my typing there. More specifically, only 'š' and 'ž' work as expected, while both Alt-; and Alt-' give me a 'c' (instead of 'č' and 'ć'), and Alt-] gives a 'd' (instead of a 'đ').
I'm using AutoHotkey_L (though I had the same results with the "regular" AHK), Vim 7.3 (trying this in gVim; it doesn't work in the terminal version either (in a slightly different way) but I don't really care about that) on Win8.
I can give more info on the Vim version, but it's basically one of those windows binaries from vim.org. Things I guess might be important is that it has +multi_byte, and I've been using Unicode in it with no problems whatsoever.
Update:
As per Ingo's suggestion below, I've tried using IfWinNotActive to not have the mappings present in Vim and continue to use my old ones there. Here's one example I've tried
SetTitleMatchMode 2
IfWinNotActive GVIM
{
#CommentFlag //
!;::Send {U+010D} // č
!'::Send {U+0107} // ć
!]::Send {U+0111} // đ
![::Send {U+0161} // š
!\::Send {U+017E} // ž
}
I've also tried many other variations with the Vim window class (using ahk_class), with #IfWindowNotActive etc., but to no avail... The mappings are still there in Vim. Btw, the window title always contains the string "GVIM", and AHK sees that as I've confirmed with WinGetTitle.

I don't have a solution, but a workaround: When I faced with the same issue, I decided to emulate Vim's digraphs globally (also using AutoHotkey), and just except Vim (and applications like Remote Desktop) from that feature (so that the full range can still be used there; my script only supports a subset). You can find my implementation here.

You can also edit a keyboard layout itself, using Microsoft Keyboard Layout Creator.
For example, the English one that you use: choose combination of some character and some function key (Ctrl or Right-Alt, with or without Shift − e.g. for Caps).
Here’s how it looks:

I find the Apple International US layout very good for this purpose, having all the accents available using dead keys, so I've implemented it with Microsoft Keyboard Layout creator like stansult suggested.
Then I came up with the problem of having only one "Alt" key usable, so I ended up remapping my Windows and Alt keys using ScanCodemap. This is a viable solution if you don't use the Windows key that often. One caveat of this method is, that you'll have to use Win+Tab instead of Alt+Tab from now on to switch between windows, it takes a couple of days to get used to that.
Windows Registry Editor Version 5.00
; 0x003a001d: Caps Lock (0x3a) -> Left Ctrl (0x1d)
; 0x0038e038: Left Alt (0xe05c) -> Right Alt (0x38)
; 0xe05b0038: Left Windows (0xe05b) -> Left Alt (0x38)
; 0xe05c0038: Right Windows (0xe05c) -> Left Alt (0x38)
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,05,00,00,00,1d,00,3a,00,38,e0,38,00,38,00,5b,e0,38,00,5c,e0,00,00,00,00

Related

Dyalog APL - Disabling APL symbol input

I recently obtained a personal licence for Dyalog APL and started using it (I'm switching over from APLX). I really like it, but whenever I'm not using the IDE, the APL symbol keybindings persist. For example, if I try to undo something in another application by hitting CTRL-Z, I'll instead get ⊂ and the undo will not go through. Similarly, attempting to use CTRL-S to save a document will result in me typing ⌈ instead of saving. The only way I've been able to resolve this is by restarting my computer.
How can I disable APL symbol input after the IDE is either not in focus or has been closed? If there's no way to do that, is it possible to map the symbol shortcut to ALT instead of CTRL? ALT is used far less often than CTRL for shortcuts, so I could live with that.
I'm using Windows 8.1 64 bit and the 64 bit version of Dyalog APL with a US keyboard.
If you want to use AltGr (right side Alt) to enter APL symbols while keeping a normal US layout or an almost normal UK layout, you can use my keyboard layout instead of the IDE. This avoids almost all clashes with other applications, so you can keep the keyboard active at all times and forget about mode switching.
Dyalog uses a standard Windows mechanism called "IME" (Input Method Editor) to enable input of APL-Characters. The advantage is that this enables you to use APL-Symbols anywhere - but obviously there is a 2nd side to that.
The "challenge" in your setup is only to change the IME back from APL to regular text-mode and this does not need a reboot. Pls check this article for more info on IME: https://www.google.de/amp/www.thewindowsclub.com/input-method-editors-windows/amp
(Sorry, I'm using W10, so I rather refer you to that article than giving wrong info... BTW, the advantage of W10 is that the IME will be default work in application-mode, so you can go to WinWord there and use default hotkeys w/o switching IME.)
Edit: For those using W10 (and probably W11) that article is out of date. The Languages settings are no longer in the Control Panel and are now in Settings. Go to Time and Language>Keyboard>"Input language hot keys" and change the Key sequence for "Between input languages". The "Switch Keyboard Layout" shortcut will be the one that toggles between keyboard layouts (I have Shift+LeftAlt toggling between Dyalog and US). You can also see which keyboard you are using on the taskbar by adjusting "Language bar options" on the same Settings page.

Creating your own LaTeX keyboard layout : 1 key = multiple caracters

I've been looking for the answer for quite some time now. This is a project I have but I can't manage to find a way to do it. The main idea would be to plug an additional keyboard on my computer that write multiple letters by hitting only one key. For example, instead of writing down a (when I hit the a key), it would write \textbf{ (for example).
I already manage to find the keyboard layout file under Linux and to switch the a and b keys, but I cannot find a way to print multiple characters.
I know it exist editors (like Texmaker or Kile) that have auto-completion, but I'm most of the time working in project in groups and therefore we use writelatex.com which does not propose auto-completion in it's free user pack ! Besides, I'm doing that for my personal interest.
Thanks a lot.
Have a look at autokey. It can assign phrases to hotkeys. It requires X11.
Another option might be to use a powerful text editor like vim or emacs which both have features like this, and then copy/paste the text into writelatex.com.
Some browsers have add-ons that allow you to edit the contents of a text field on a web page with a chosen text editor.
Edit: In Xorg you can use the X KeyBoard extension to e.g. change the meaning of individual keys. While you can configure the keyboard to generate (multibyte) unicode characters, you cannot assign arbitraty character strings to one key, to the best of my knowledge.

Dvorak typers, how do you handle shortcuts like Ctrl-C?

Do you change the key binding in the OS to be, i.e., Ctrl-Q?
Do you manage to stretch your left hand to the C key?
Do you use right ctrl and press shortcuts with your right hand?
When I switched to Dvorak, I was using primarily Ctrl+Ins and Shift+Ins for copy/paste. Now I use Ctrl+C and Ctrl+V and other program-specific shortcuts, but I have just learned to use them in their "weird" locations.
A similar question was asked on SuperUser, with the following answers:
Use an AutoHotKey script to remap the keys. (Link)
Use Microsoft Keyboard Creator to remap them. (Link)
Install a third-party app that will remap them automatically. (Link, Link)
macs have it built in. there is a keyboard layout for dvorak with querty shortcuts. for windows, i use https://code.google.com/p/dvorak-qwerty/ it works well with ctrl and alt but dosen't work with the Win Key, which is not that bad.
The program AutoHotKey is what I use to map C,X, and V to their Querty origin.
I use none of the proposed solutions: instead, I modify CapsLock so that it becomes a dead-key that I use to program various actions. For example, when I press CapsLock and the key marked (in QWERTY)
S, this is mapped to Ctrl-X (and thus cut)
D, this is mapped to Ctrl-C (and thus copy)
F, this is mapped to Ctrl-V (and thus paste)
I, this is mapped to up-arrow
K, this is mapped to down-arrow
J, this is mapped to left-arrow
L, this is mapped to right-arrow
etc.
This is was dubbed 'Home Row computing' by Gustavo Duarte when he introduced this idea in https://manybutfinite.com/post/home-row-computing/ and then https://manybutfinite.com/post/home-row-computing-on-mac/
I'm pretty sure that this amounts for a large part of the speed I gained when typing, in addition to touch-typing.
On Linux, the solution that works great with some versions of Gnome on Wayland is this. It will set up all the rules on installation and will work transparently.
Previous answer:
Using Cinnamon, the following works when typing in some applications (i.e. vscode editor):
In keyboard settings, add QWERTY keyboard layout as the first in the list,
add Dvorak layout as the second
When typing text in an editor using the Dvorak layout, pressing Ctrl will still use the first (qwerty) layout.
This does not work in other applications, like Firefox browser, for example so can be pretty confusing.
Having a shortcut (i.e. Alt+Shift) for switching layouts assists in those cases.
While can be difficult at times, the advantage of this approach seems to be that it does not require additional software.
I've written Dvertkey, an AutoHotKey script, for this.
I've been a dvorak user for sixteen years, and for years I've used the various alternative keymaps mentioned in this thread, but all of them fall down when using a number of recent incarnations of Microsoft applications, such as the Office apps and SQL Server Management Studio. They seem to ignore Windows' own keymaps when using meta keys, rendering the hybrid layouts useless. AutoHotKey gets around this to ensure I get exactly what I want in any application.
I've been using Dvorak for so long now that I couldn't imagine remapping ctrl-c and other hotkeys to be in any other location than where they are supposed to be on the Dvorak keyboard. As for hotkeys, it's much easier and more natural to just use two hands to do the combinations. Use the left hand for ctrl and the other hand for the c-key. It would be too confusing to try and think ctrl-c and then press something else.
For the occasional windows game that requires WASD, I just switch the keyboard for the duration and if that means typing QWERTY sentences in chat then I just mentally switch and type a little bit slower.
Those characters are accessible with the right control key (a bit of a stretch for the x). If you are right handed, and have your right hand on the mouse, just move your left hand to the right control key and do the key combination

how to type single quote in J gtk terminal under Windows 7

I just started programming J. Now I want to type
text=: 'hello world'
text
in the gtk terminal, which when run should display:
hello world
But when I type the single quote character it renders as ´, not as ' in the gtk terminal. And then when I run the program the interpreter says "spelling error".
Now the only way I can put a ' in the terminal is by typing it in notepad and pasting it in the gtk terminal. I find that cumbersome.
Now my question is:
Is there an easier way to type a ' in the gtk terminal?
I have Windows 7 64 bits version, also 64 bits version of J, version j64-701.
I just encountered this problem as well, and it appears that this is caused by a keyboard setting (controlling whether quotes appear directly or can be used to make é, ë and the like).
This setting can be changed in almost all Windows applications by pressing Left Alt + Shift. After using this combination, the single quotes appeared correctly for me.
HTH.
I've faced exactly the same problem and I found out that it happens in every software that uses GTK+ (Pidgin, GIMP, Geany, etc), if you have set your keyboard to English-International, when you press the single quote(')/double quote(") key, what you get is acute accent(´)/diacritic(¨).
The best solution to me was, adding the English-US keyboard to the list of available keyboards in Windows (yes, this solution is for windows but you can easily do something similar in any SO you are facing the same problem).
And when I want to input an [ ' ], I just press the default combination LEFT CONTROL + SHIFT to toggle between keyboards.
Long shot, but I'm guessing it's a keyboard thing. My French keyboard has a funky layout, and yours (I'm guessing Dutch?) might have one too. I guess I'm lucky, under Vista 64, I get single quotes, with the right key.
I think it's a bug of the specific version of J. I will ask this question to the support of the producers of J.

Shortcut with meta-shift key doesn't work in emacs

I can't use any shortcut that has meta-shift (alt and shift) in it because ubuntu will treat it as "change keyboard layout" shortcut (I map it to alt-shift since I use the same shortcut in windows) as soon as I press m-s. In windows change keyboard layout shortcut doesn't register until you release the key so any shortcut with m-s is usable in windows.
Is there any work-around without changing shortcut or meta key ? I kinda used to it.
Change the Ubuntu change-keyboard-layout shortcut, to something else.
Or use Esc as Meta
Nothing easy that I know of.
You can manually bind everything that's M-S-??? to C-M-S-??? in your .emacs or at least all of the ones that you use...
Or you can just change the short-cut... how often do you change the keyboard layout? (I use dvorak, and qwerty, but I've never needed a shortcut for it, I just use the button...)
I have tried different things, and in my opinion it is best to change the layout shortcut to something else. The power of emacs is all in its shortcuts that are available right there under your fingers. If you move the M key away and make it harder to reach, it will most surely have a negative impact on your editing speed.
Right now I'm trying to get used to switching layouts with the right Alt key. I almost never use it for anything, so missing it won't be a problem. And from my experience teaching yourself to switch layouts with another combination is a matter of several days.
P.S. Also it pays to use Caps-Lock as an additional Ctrl key, it helps tremendously!

Resources