Rob Kwasowski
Rob Kwasowski

Reputation: 2780

Making an Atom package in JS: go to line

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

Answers (1)

Luis Estevez
Luis Estevez

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

Related Questions