Sublime Text go to character number

Sublimetext3Sublimetext

Sublimetext3 Problem Overview


How can I go to N-th character in the file. Ignoring all the line breaks, N-th character in the whole file.

Similar to this vim command, but in sublime text

Sublimetext3 Solutions


Solution 1 - Sublimetext3

Open Goto Anything or Goto Line (accessible from the Goto menu, if you are not using keyboard shortcuts).

Type ::N where N is the Nth character in the file that you want to go to. i.e. precede the number with 2 colons.

(Goto Line will prefill one :, so you only have to type one more. Alternatively, you could create a keybinding to execute command show_overlay with the following args, to prefill 2 colons: {"overlay": "goto", "text": "::"})


Alternatively, use the Find panel to search for the following regex:

\A[\s\S]{N-1}\K

replacing N-1 with the desired character number minus 1.

  • \A anchor from the beginning of the file
  • [\s\S] any whitespace or non-whitespace character
  • {N} match the previous character class N times i.e. {99} times so you end up with the caret immediately to the left of the 100th character
  • \K clear what has matched so far

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAndriiView Question on Stackoverflow
Solution 1 - Sublimetext3Keith HallView Answer on Stackoverflow