Keyboard layout for programming fr-ca user - keyboard

I already know this has been asked countless times, but here is the problem.
I am thinking about making my typing speed up and right now the pick and hunt method that I badly gained using qwerty has made me a slow typist (qwerty makes me fell clumsy). I am using a laptop and I'm not afraid to learn a new layout.
I have been looking at Dvorak for a while but i am not convinced yet because I need a layout that I can use for both writing and codding with access to accents eg: êèé and ç
because I am french Canadian.
As far as I can see these are hard to meet, still I could be wrong.
Thank you all, have an amazing day.

Take a look at EurKEY. It is based on the US standard layout, which is best for programming and you have access to é, à, è, ù, ë, ï, ö, ÿ, ç, œ and æ and all capital counterparts. The circonflex letters, â î ô û, however are a bit difficult to reach. The keyboard is available for Windows and MAC OS X, and it's already included in many Linux distros. All free.

Highly recommend Eurkey myself. At work we use qwerty keyboards (still great for coding) but for writing in French, it is a pain in the a**. Have a look at Eurkey, uses the normal querty layout but in addition all special characters are easily accessible using the altGR key.

I personally built my custom layout using Microsoft keyboard layout creator.
The idea is to use the altgr key to create enable typing new symbols using the home row.
the layout looks like this:
no shift:
1234567890)=
azertyuiop=-*
qsdfghjklm_
wxcvbn,;:!
shifted:
&é"45-è_çà)+
AZERTYUIOP+$/
QSDFGHJKLM%
WXCVBN?./§
altgr + a: "
altgr + z: '
altgr + e: {
altgr + r: }
altgr + q: <
altgr + s: >
altgr + d: (
altgr + f: )
altgr + w: |
altgr + x: &
altgr + c: [
altgr + v: ]
Most of the symbols used for programming are available without moving your hands too much.
Also, there are a few duplicates, if that bothers you just put something else instead. I chose to keep the duplicates because it minimizes the pain for everybody else who might need to type something on my keyboard.

Related

How do I capture "CTRL + ARROW_KEY" with PD/NCurses?

While I figured out that I can just use something like #define ctrl(x) ((x) & 0x1f)2 for most plain ASCII (non numerical or [obviously] symbol) characters, I was unable to find any info or documentation on how to capture CTRL + ARROW_KEYS or any other sane\logical combinations of CTRL + SHIFT + ch and so on...
The reason I care about this, is because I am trying to maintain a project called unicurses and while I'm trying to maintain this project I'm also making a prototype demo of a terminal based editor with it where I need to capture those kind of key combinations and so I was looking for some help (also I really don't care if the answer will be in c\c++, python or whatever, I'm just looking for a way of doing it)
Any Idea?
Try the "Input Test" in PDCurses' testcurs demo. You'll see there that CTRL + Up Arrow is returned as "CTL_UP". The full list of named keys is in curses.h. Some combinations can only be distinguished by their modifiers, as returned by PDC_get_key_modifiers().
I'm not sure how or whether you'd do it in ncurses.
In general, I recommend you avoid these exotic key combos.

OSX: Remap Caps Lock as a modifier key likey cmd

The standard layout on an a macbook pro is not quite efficient if one wants to do a lot of programming. I want to change that with some small tweaks.
One of those would be: Change Caps Lock to be a key like cmd and ctrl. For example if I want to write '{' I want to press 'Caps + a'.
Is that possible?

What alternatives are there for easier access to {, [, \ in non-US keyboard mappings?

All my life as a developer I was annoyed that on german keyboards some common programming characters are mapped to very awkward combinations:
[ = AltGr + 8
] = AltGr + 9
{ = AltGr + 7
} = AltGr + 0
\ = AltGr + ß
As I'm touch typing with 10 fingers, I regularly have to leave the standard finger position to type the above characters. While I've somehow got used to it, it still makes me shiver whenever I have to type lengthy combinations of the above symbols.
There are suggestions to use US keyboard layout instead but this again makes it very hard to type the umlauts äöüÄÖÜß.
So i wonder: What smart solutions have other non-english developers come up with to avoid these awkward shortcuts?
I'm primarily interested in workarounds for Windows. But as a vim user I'd also like to hear vim-only solutions.
Not an actual workaround, but an alternative solution that works well for me: use the US keyboard layout for programming.
Vim's choice of keys is closely related to the US keyboard layout. On a US keyboard,
/ is to ? (Shift/) what n is to N;
/ is extremely convenient to reach, and unshifted;
{ and } are in the same place as [ and ], they differ only in shifting;
+ "line down" and - "line up" are adjacent;
: is on the home row;
< and > are neighbours;
all characters commonly used in programming are accessible with Shift, there is never any need for AltGr or CtrlShift etc. combos.
The last point is especially important. Vim's command language is about eliminating modifier keys so having to use only the Shift modifier is good.
At some point I realized how my keyboard layout held me back. I switched to the US keyboard layout for programming only. I have been doing all my programming and terminal hacking in the past few years on a US layout and I'm very happy with it. Whenever I need to write an email or make notes I can just switch back. The keyboard layout is like a representation of the mindset I'm currently in: US for programming, native for other things.
I say, give it a try.
Not only for that reason, but because of the better layout, I learned the dvorak for programmers layout. I don't recommend you to learn the whole layout - it took me monthes to reach my old qwertz-speed.
But the sticking point why this layout is explicitly recommended for programmers is the alignment of the numbers-row. The numbers are in shift-position whereas the symbols are in first position (but in a better alignment as in standard-qwertz and even qwerty). So for example if I hit the qwertz-5 I get ( instead, 8 is ) and so on.
Here you can see the whole layout.
You also have to leave the "normal" keys and reach the numbers-row, but if you train it a bit, it feels really awesome inside vim and while programming.
So one option is to customize your standard-qwertz layout (maybe using the Microsoft Keyboard Layout Creator or any other tool) to get the special keys better positioned, like for example in the dvorak for programmers layout.
Another option is using qwerty and remapping the german umlauts to AltGr+a for ä, AltGr+s for ß and so on. That's what I also did with dvorak.
It's not that handy as on standard qwertz, but those characters don't occure that often, I think.

Vim: remapping Shift-Cmd-Opt-Ctrl to Escape

It seems like this article by Steve Losh has been making the rounds, and in short, it led me to remap Caps Lock to F19, and at the system level, to remap F19 to Shift-Command-Ctrl-Alt, thus giving me an entire namespace for my own keyboard shortcuts.
The problem is I enjoyed using Caps Lock as my escape key in Vim.
I tried :map <M-C-D-S> <esc>, but upon sourcing, hitting caps lock doesn't do anything. I'm guessing it's because Vim expects an actual key to be pressed with the modifiers.
My question is: is it possible to have Vim read Shift-Cmd-Ctrl-Alt as Escape?
No, you can't map four modifiers. Not even three, Not even two. And, well… not even one.
"Modifiers" are called "modifiers" for a reason: they are used with normal keys to "modify" their meaning. The Shift, Alt, Cmd and Ctrl keys don't do anything on their own and Vim rightfully does nothing but wait for further keypresses when you hit them.
Additionnaly, Vim's input mechanism is a bit "old school", most probably to keep it consistent over the multiple platforms it may run on. It won't register more than one modifier with a normal key. That means that, if the terminal doesn't eat them up (which it does), you can only do <C-…> or <S-…>. The Alt key is not really a working solution because of how many terminal emulators deal with it and the Cmd key is Mac-only and only works in MacVim anyway.
At that point, if you are ready to mash four keys together to emulate the function of only one key (which in itself is rather silly), you might as well simply use <C-c> which, AFAIK, works everywhere. Your left hand will thank you.
My original question suffers as an XY Problem.
You want to do X, and you think Y is the best way of doing so. Instead of asking about X, you ask about Y.
I wanted to Vim to read Caps Lock as Esc (while still maintaining the other crazy system-level modifications), so I asked about functionality that Vim doesn't have.
Turns out, while the answers provided above were great, on point, and informative, I just don't like being told 'no.' And I was searching for answers in the wrong problem space.
One of the applications discussed in the OP's link, KeyRemap4MacBook, is highly extensible. The documentation leaves much to be desired, but I was able to piece together a solution in line with my original question. This diverges sharply from the original topic of "map stuff in vim," and for that I apologize, but I hope to leave this in posterity for the one poor soul that needs this.
Simply put, the previous article recommends adding this to KR4MB's 'private.xml' file:
<item>
<name>Remap Caps Lock to Hyper</name>
<appendix>OS X doesn't have a Hyper. This maps Left Control to Control + Shift + Option + Command.</appendix>
<identifier>caps_lock_to_hyper</identifier>
<autogen>
--KeyToKey--
KeyCode::F19,
KeyCode::COMMAND_L,
ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L
</autogen>
</item>
(modified slightly for Caps Lock)
This can instead be changed to:
<item>
<name>Caps Lock to Hyper OR Escape</name>
<appendix>Caps Lock should be remapped to F19 (80) in PCKBH</appendix>
<appendix>This remaps F19 to "Hyper" aka Cmd-Shift-Ctrl-Alt...</appendix>
<appendix>...but, when pressed alone, F19 sends only escape</appendix>
<identifier>remap.hyper2hyper_escape</identifier>
<autogen>
--KeyOverlaidModifier--
KeyCode::F19,
KeyCode::COMMAND_L,
ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L,
KeyCode::ESCAPE
</autogen>
</item>
This tells the system that whenever Caps Lock is pressed alone, it's actually Esc, but if it's pressed in conjunction with any other key, it's F19.

In Vim, why is 'j' used for down and 'k' for up?

I've been using Vim for many years and have never really thought about it. A friend of mine asked why that is, noting that in our culture, left would usually map to up while right would map to down, making the Vim keys backwards.
I understand that they are on the home row, meaning that you do not have to move your fingers anywhere to hit them, but that's a different point altogether.
Why were these keys given their present purposes? Is there some documentation on the decision as well?
The answer is in the Wikipedia entry for vi. Bill Joy, who wrote the visual mode of ex - which ended up being Vim's precursor vi - used a Lear Siegler ADM-3A terminal on which the HJKL keys mapped to left, down, up, right - and it’s been that way ever since.
Here's the keyboard layout:
A couple of other points of note on the ADM-3A layout:
Left of the Q: the escape key - somewhat handier than where it is on keyboards today, hence a good choice for switching between normal and insert modes.
Top right: the 'Home' key doubles as the tilde (~), which subsequently became shorthand for a Unix user's home directory.
vimtutor provides the mnemonic that 'J' looks vaguely like a downward-pointing arrow, though that may or may not be the original reason why it was chosen.
This is a total guess, but: The Ctrl+J character is the "line feed" character, which on a traditional TTY moves down one line, providing a mnemonic. K was right next to it on a Qwerty keyboard, under the second most commonly used finger on the right hand when in the home position.
Simply to supplement all the answers, here is the photo of the ADM-3A keyboard (the exact keyboard on which Vim has been created).
P.S: I wish they had used W, A, S, D
From a user experience perspective, after you open a file, you always move down first and moving down is usually a more frequent operation. Since from left to right is the natural direction for most of us, it make sense to associate the task you perform first or more frequently with the key on the left. You can try to switch the 2 keys and try to tell which way is better. For me, "J" for down is more natural and comfortable.
It explains it if you run vimtutor in the terminal. It says:
The h key is at the left and moves left.
The l key is at the right and moves right.
The j key looks like a down arrow.
I always thought it was because on the Dvorak layout, j and k are also next to each other. There are not many keys that have this property on both Dvorak and A/QWERTY/Z.

Resources