Reputation: 2780
I'm making an Atom package in JavaScript. How do I jump to a particular line, similar to what you can do with Ctrl-G. Is there a function like goToLine(line) that I can use?
Upvotes: 1
Views: 85
Reputation: 1417
atom has a pre-installed package called go-to-line and has a function navigate. it's as simple as this:
import { Point } from 'atom';
const editor = atom.workspace.getActiveTextEditor();
const position = new Point(row, column);
editor.setCursorBufferPosition(position);
editor.scrollToBufferPosition(position, { center: true });
Upvotes: 1