3

If you run vi/vim in screen, when you press a cursor in insert mode, you get a new line + a character, which is a pain.

How can I configure vim to move around instead?

Tim Abell
  • 1,311
  • 3
  • 10
  • 21

4 Answers4

4

Put the following in you ~/.exrc file

map! ^[OA ^[ka
map! ^[OB ^[ja
map! ^[OD ^[i
map! ^[OC ^[la

Note: ^[ is the “ctrl-v Esc” key presses. Copy and paste will not work.

Tim Abell
  • 1,311
  • 3
  • 10
  • 21
2

Start vi with

vim

instead of

vi

as vim isn't affected by this issue!

Tim Abell
  • 1,311
  • 3
  • 10
  • 21
  • 4
    I assure you vim is definitely affected by this. – ScaryAardvark Apr 13 '12 at 12:40
  • It could be an ubuntu/debian thing I suppose, maybe the config is different. I'd forgotten about this problem! – Tim Abell Apr 16 '12 at 09:51
  • Vim isn't affected by this on Ubuntu 18.04, so the question now would be 'How do you turn off all the annoyingly garish colors in vim' or better 'How to avoid using vim by allowing cursor functionality in vi' – Hektor Aug 14 '20 at 23:45
2

Arrow keys are nice, but you should try to get used to using "hjkl" to move around in vi. This always works, so you won't need to worry about changing the config file on every system where you have this problem.

brianmathis
  • 211
  • 1
  • 2
  • 5
0

"Get used to "hjkl"" : the best answer. Saving yet another customisation to keep track of.

JPGConnolly
  • 101
  • 1