I'm just learning how to use the vi editor, and was trying to make use of the following map command in my .exrc file:
map K 0I^I^[j0O^I^[j0
That is what appeared when I created the map in ex mode and typing it in manually gave me those escape codes. I wanted to:
- go to the start of the line
- press Tab (
- go down one line
- go to the start of the line (unnecessary I guess)
- open a new line below
- Tab again
- go down one line and
- go to the start of that line
But it doesn't work! It does the
0 and the
I, but then inserts the remaining map keys as if in insert mode
^I^[j0O^I^[j0. Please tell me, someone, why it doesn't work? What am I doing wrong?
Follow-up: I double-checked what I did. If I type in the keystrokes in a :map command while in ex, whether I escape the Tab with Ctrl-v or not, it prints just a plain, single "^I" for each Tab. So when I keyed in the same thing WHILE EDITING MY .exrc FILE, when I make sure I type Ctrl-v Tab, IN THERE, it displays a bunch of whitespace for each Tab, untranslated into an escape code! And when I go back to vi and try it out, NOW it works. Perhaps it's because "in vi", where I was really using ex (since I was typing in ":map"), I was really IN EX, but since the map commands in the .exrc file don't need the initial colon before "map", I was starting the entry without a colon, and I was really using vi, not ex! Maybe that was what caused the disparity?