A message for Linux.com registered users: We are in the process of making changes to the Linux forums. Starting Monday, 8/13/18 at 6:00 PM PT, you will be unable to access the forums. They will re-launch as soon as possible on Wednesday, 8/15/18 with new features and improved functionality. Thank you for your patience and stay tuned for the new improved forums.

May 2, 2011

vi - anyway to jump line while in insert mode?



I recently am put in a situation where I will be editing code on linux boxes that have nothing but vi or vim...

and have a hope that there is a way I can jump up a line while in insert mode in vi.

The reason is simply that I noticed in vi its very hard for me to enter my braces easily. In most editors, when I write a function, I add the open brace, hit enter twice and add the second brace (to avoid compilation problems)...it seems to me in vi this process requires I enter the first brace, enter twice and add the second brace, but then I have to leave insert mode and then issue a command to jump up a line and then back to insert mode.

This process I find quite annoying and problematic as its much easier for me to just use my right hand and the arrow keys in most editors. In vi the best process I have so far is - brace, enter, ,brace ESC, O, i ..then code.

Does anyone know if there is way to jump while in insert mode similar to way you can move back with CTRL-h? It would really make life easier for me...

Thanks in advance.

Click Here!