avriis
avriis

Reputation: 1681

Move to last non-empty line in vim

Say that I have the following beginning of file. I often navigate to the top of the file with gg, but then I want to go to line 4, i.e. last non-empty line so that I can import other stuff on a new line with o. Is there a command to do that? Of course I could do 4j and then o, but the number of import lines varies across files, so in order to avoid having to look for this information everytime it could be nice just to go to the last non-empty line with a single command, so that I could simply type ´o´ and start writing.

  1 import * as firebase from 'firebase';
  2 import { firebaseConfig } from '.././config/auth';
  3 import { RkText, RkCard, RkStyleSheet, RkTheme } from 'react-native-ui-kitten';
  4 import { connect } from 'react-redux';
  5
  6 [some other code]
  ...

Upvotes: 3

Views: 925

Answers (2)

drRobertz
drRobertz

Reputation: 3638

An alternative is to go to the first empty line with } (go forward paragraph) and insert with O.

see :help object-motions for details.

Upvotes: 5

James Anderson
James Anderson

Reputation: 27478

Upper case G gets you to the last line of the file.

Upvotes: -1

Related Questions