5

I have been through at least a dozen articles and internet searches (including this one) and I cannot find a setting that satisfies what I want: Both iTerm2 (at command prompt) and VIM to recognize Home and End the way they're meant to be used.

If I set Home to hex code 0x01 in iTerm2 key mapping, it starts working at the prompt, but stops working in VIM.

If I leave it alone, hitting Home and End work fine in VIM, but not at prompt.

What the hell is going on?

I have a Mac Keybinds file (located at ~/Library/KeyBindings/DefaultKeyBinding.dict) that looks like this; and I have the same behavior when the keyword is BeginningOfLine as what's set here (BeginningOfParagraph):

{
/* Home Button*/
"\UF729" = "moveToBeginningOfParagraph:";

/* End Button */
"\UF72B" = "moveToEndOfParagraph:";

/* Shift + Home Button */
"$\UF729" = "moveToBeginningOfParagraphAndModifySelection:";

/* Shift + End Button */
"$\UF72B" = "moveToEndOfParagraphAndModifySelection:";

/* Ctrl + Home Button */
"^\UF729" = "moveToBeginningOfDocument:";

/* Ctrl + End Button */
"^\UF72B" = "moveToEndOfDocument:";

/* Shift + Ctrl + Home Button */
"$^\UF729" = "moveToBeginningOfDocumentAndModifySelection:";

/* Shift + Ctrl + End Button*/
"$^\UF72B" = "moveToEndOfDocumentAndModifySelection:";
}
3

The problem turned out to be Zshell.

New macbooks come default with zshell now, creating confusion for setting these keys on a full size keyboard. Typing bash and using that as my default shell worked without a problem, but I wanted to know how to accomplish this in zshell.

The solution was to first remove any keybindings set in iTerm for home and end; then modify ~/.zshrc with the following I got from this link:

bindkey "^[[H" beginning-of-line
bindkey "^[[F" end-of-line

Then, obviously, source ~/.zshrc.

1
  • you might wanna add, that first we need to remove the home and key bindings from iterm2 key preferences, and then set the values in ~/.zshrc as you said. Aug 12 at 5:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .