diff --git a/kilo.c b/kilo.c index 3cf390b..60880c5 100644 --- a/kilo.c +++ b/kilo.c @@ -349,11 +349,17 @@ void editorMoveCursor(int key) { case ARROW_LEFT: if (E.cx != 0) { E.cx--; + } else if (E.cy > 0) { // Go to previous line on left at start. + E.cy--; + E.cx = E.row[E.cy].size; } break; case ARROW_RIGHT: if (row && E.cx < row->size) { E.cx++; + } else if (row && E.cx == row->size) { // Go to next line on right at end. + E.cy++; + E.cx = 0; } break; case ARROW_UP: