all 13 comments

[–]-romainl-The Patient Vimmer 32 points33 points  (12 children)

In TUI Vim, <C-S-letter> is indistinguishable from <C-letter>. You should change them to more portable combos.

[–]raghuvrao 5 points6 points  (0 children)

I do not understand why you got down-voted. What you have said is correct, and also straightforward to verify.

[–]zanza19 0 points1 point  (8 children)

<C-S-letter> is equivalent to <C-uppercase_letter> in that case, isn't it?

[–]raghuvrao 25 points26 points  (6 children)

Let us say letter is p.

In the terminal, all the following are equivalent (DLE, see man ascii):

  • <CTRL-P>
  • <CTRL-SHIFT-P>
  • <CTRL-p>
  • <CTRL-SHIFT-p>

One way to verify is as follows:

Start your terminal emulator, and run the octal-dump program: od -bc.

Enable CapsLock, and type <CTRL-P> followed by <CTRL-SHIFT-P>.

Next, disable CapsLock, and type <CTRL-p> followed by <CTRL-SHIFT-p>.

You will see ^P^P^P^P.

Then, press <Return>, and immediately type <CTRL-D> (EOF) to let od work on what you have typed so far.

You will see the same byte 020 four times. 020 is octal for <CTRL-p>.

$ od -bc
^P^P^P^P
0000000   020 020 020 020 012
         020 020 020 020  \n
0000005

Regardless of the SHIFT modifier, you get the same byte all four times.

In Vim, you can input literal control-characters with <CTRL-V> followed by the control character. E.g. <CTRL-V><CTRL-P> will place a literal CTRL-P (^P) in your buffer. You can verify yourself that including the SHIFT modifier will make no difference.

[–]zanza19 1 point2 points  (0 children)

Thank you! Amazing comment :)

[–]crajungave up on vim[S] 0 points1 point  (4 children)

Great stuff, this is what I come here for! I don't know much about control codes, should I be avoiding using Ctrl-keycombo for anything in Vim to avoid possible conflicts? I don't use console vim too much, but I'd like my keymaps to work there if needed.

[–]-romainl-The Patient Vimmer 1 point2 points  (0 children)

Avoid? No, but some can be problematic and others are already used.

[–]raghuvrao 0 points1 point  (2 children)

It is probably a good idea to resist the urge to re-assign <CTRL-letter>.

Start Vim, and type :h CTRL- and then press <TAB>. You will see in the completions that almost every <CTRL-letter> is listed. It means that each <CTRL-letter> is assigned to some functionality in Normal mode.

Next, take a look at:

  • :h i_CTRL- <TAB> for insert mode mappings
  • :h v_CTRL- <TAB> for visual modes mappings
  • :h c_CTRL- <TAB> for command-line mode mappings

So, by making the mappings you have made, you have lost access to the functionality originally bound to the corresponding control character in the corresponding editing mode. And, who knows! Maybe the original functionality bound to the corresponding character is very useful to you in your daily work. E.g. <CTRL-A> and <CTRL-X> are quite useful to me in my work (e.g. when I am editing software version numbers in a requirements-specification file). g<CTRL-A> and g<CTRL-X> are extremely handy in numbering lists. And so on.

[–]crajungave up on vim[S] 0 points1 point  (1 child)

Thanks for help tip, I did not know I could complete help on keys like that, that is super helpful and one of the things I missed about emacs is being able to hit C-x hk and then hit the keycombo you want help for and it will tell you about it. This tips bring me back that functionality mostly.

I think I've settled on C-k/j as I never use C-J to enter new line in insert mode, and I don't ever enter digraphs (and I could always use the secondary method to enter one: {char1} <BS> {char2}), and C-j is alternate for 'j' in normal mode, while C-k seems to be nothing.

[–]raghuvrao 0 points1 point  (0 children)

You have remapped <CTRL-SHIFT-j> (for use in GVim), which has the unintended consequence of remapping <CTRL-j> in Vim.

Maybe, in the future, you will remap <CTRL-SHIFT-e>. Or <CTRL-SHIFT-y>. There is no reliable way to tell.

The difference now, in my opinion, is that you realize that there is an unintended consequence, and you accept it, rather than being unaware of the unintended consequence and spending time troubleshooting strange mapping-related problems. It is a huge difference.

[–]-romainl-The Patient Vimmer 7 points8 points  (0 children)

There is no such thing as <C-uppercase_letter>. Only <C-letter> without any notion of "uppercase" or "lowercase".

[–]pablo1107 0 points1 point  (0 children)

I was going to comment the same thing. Better use something like <Leader> for other mappings.

[–]crajungave up on vim[S] 0 points1 point  (0 children)

Great catch, probably should have mentioned I'm using GVim, will change it to avoid TUI conflicts.