Open file at specific line and column


#1

Hello,

I would like open a file and position the cursor on a specific row and column like this:

atom file.txt:20:10

and it would go to line 20 and column 10.

Would such feature be possible to implement as a package?


#2

+1. This would be nice to have. I wonder if it calls for hacking of the core files (atom.sh, atom.js) to get opts or if they pass through.


#3

Indeed, very useful when clicking an exception or some other part of a stack trace lands me at the correct line.

I went through the API and it seems command line options are not passed through. On the other hand, moving a cursor to a specific position is of course supported.


#4

We don’t support columns right now, but you can open a file to a specific line like this atom my-file:34


#5

Oh, I didn’t notice that and I think I know why. It works when I open the file for the first time but after that it is ignored:

If I type

atom file.txt:10
atom file.txt:20

the cursor stays at line 10. Is this intentional? It makes the use case I mentioned earlier more tedious.


#6

@ncr That sounds like a bug. I’ll add it to our issue tracker.


#7

Any news on this? Should be an easy fix. This is really important for users that write LaTeX files. Sadly, Sublime Text remains my go-to editor until this is fixed.

Thanks for making a great editor!


#8

Here’s the bug that was opened:

You can click the Subscribe button to be notified when there are updates.


#9

Is there a way to do this from the API (e.g. https://atom.io/docs/api/v0.176.0/Atom#instance-open)

Update : pathsToOpen: [definition.fileName+":30"], will just work. Nevermind.


#10

And this feature was added a while ago … so I’m closing this as fixed. :grinning:


#11