How to navigate to character location in WebStorm?
Asked Answered
C

5

10

I'm wondering how can I can navigate to a character location? I have a script that will tell me the character location number, no line number.

INFO: log-process/3093 on local-machine: Some Log Message

The 3093 is the character location number.

Confederacy answered 17/3, 2015 at 15:44 Comment(0)
I
34

I do this by selecting code from the start of the file. Then, total number of selected characters is displayed in the bottom right corner, so I can find the character that I only knew the number of.

Indochina answered 1/8, 2018 at 13:28 Comment(5)
While this might be a valuable hint to solve the problem, a good answer also demonstrates the solution. Please edit to provide example code to show what you mean. Alternatively, consider writing this as a comment instead.Cress
@TobySpeight - not sure I follow your suggestion. David's suggestion is a pretty good solution to OP's problem.Exemplum
So far this is the only way to do it that I see, not really the most convenient way of doing it~Confederacy
@TobySpeight but David's sugggestion is a solution which does not require code...Piero
Ah, so this is an answer for manual, interactive use?Cress
N
5

In WebStorm, if you mouse click on the file line and char count in the bottom bar:

enter image description here

it will open up a dialog where you can type in the line and char position:

enter image description here

Normalize answered 10/4, 2020 at 17:9 Comment(4)
Is this some new feature o.o how did I never notice this!Confederacy
if i just put in a character number, does it also just go to the character count?Confederacy
No. A single number is treated as a line to go to.Corncob
This doesn't answer the question. Lots of times you'll just have a single offset into the file, like character at position 13743. There's no way to translate that into line:column.Incorporator
H
3

No such navigation action exists. You'll need to either 1) Search for a plug-in that will do this; 2) write your own plug-in to do it; or 3) Open a feature request to add such functionality.

UPDATE

The "Go to Line" dialog was enhanced to be "Go to Line:Column". You can open it by:

  • Ctrl+G / +L
  • Menu: Navigate > Line:Column
  • Click on the cursor position in the bottom right of the window. For example: cursor position indication

This will open the Go to Line:Column dialog:

Go to Line:Column Dialog

In the dialog, you can enter a value such as 10:15 to go to the 15th character on line 10. You can also enter just a line, 10 which will take you to the start of that line (line 10 in this example). Or you can enter just a character position, for example :15, which will take you to that character position on the current line.

However, I am still unaware of a way say "Navigate to the Nth character position in the file". And the original poster's feature for such a feature is still open.

Hayne answered 17/3, 2015 at 20:2 Comment(1)
I created youtrack.jetbrains.com/issue/IDEA-251798 I couldn't find an existing issue, which surprised me after all this time.Corncob
A
1

I had the same situation today. I have a minifed and uglified javascript file, and I was simply searching manually for error (14, 4974). In the bottom right corner of Webstorm, you can see the line number and character position.

enter image description here

Searching for lets say line 14 and position 18438 is not an easy task, but clicking inside the script file may help you to pin point the location.

Archi answered 15/9, 2017 at 10:26 Comment(0)
E
0

Install the IdeaVim plugin.

Then type:

:normal! 0go3093 "

Your cursor will move to character 3093.

You can make this into a simple command by typing:

:command! -nargs=1 GoToChar execute 'normal! 0go' . (<args>-1) . ' '

Now you only have to type:

:GoToChar 3093

To go to character 3093.

Exeunt answered 10/12, 2023 at 21:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.