Sublime Forum

Always show Line, Column, even when Find is active?

#1

Is there any setting or hack that would move the “Line, Column” display to the right end of the status bar, like Encoding, Line Ending, Tab Size? There is usually plenty of blank space, but the Line, Column field is always at the left end where things like Find match count cover it up… Even if you unselect multiple chars…

Guess we have to Esc out of find to see cursor position, and then Ctrl+F again?

0 Likes

#2

You can’t move the general position of the display, no. However, if you’re using a recent build of ST4, you can achieve a display of the line and column and all times, even if find results are shown.

First, set this setting in your global preferences to turn off the internal line/column display:

	"show_line_column": "disabled",

And then use a plugin like this to bring it back. Plugin defined status areas always are visible, but they’re also always to the left of imposed text like the text that display matches.

import sublime
import sublime_plugin


class ShowLineColumn(sublime_plugin.EventListener):
    def on_selection_modified_async(self, view):
        line, col = view.rowcol(view.sel()[0].b)
        view.set_status('_lc', f"Line {line+1}, Column {col+1}")

    on_new_async = on_selection_modified_async

Side note: The internal functionality for this displays the location of the first cursor, or tells you how many selection regions there are if there is more than one cursor. This plugin always shows you the position of the first cursor even if there are multiple.

You would need to adjust it if you’d rather it more closely mimic the internal functionality here.

2 Likes

#3

For newbie users like me, maybe start here:
https://docs.sublimetext.io/guide/extensibility/plugins/

Find your plugins - for me:
C:\Users\loren\AppData\Roaming\Sublime Text\Packages\User

Find the Ctrl+right_apostrophe console - (top left of keyboard, under ‘~’)
The console lines slide up from the bottom of any current Sublime window.

Try the hello_world.py plugin shown in the docs web page:
https://docs.sublimetext.io/guide/extensibility/plugins/

import sublime_plugin
class ExampleCommand(sublime_plugin.TextCommand):
	def run(self, edit):
		self.view.insert(edit, 0, "Hello, World!")

Console:

reloading plugin User.hello_world

view.run_command(“example”)

[“Hello, World!” appears in your edit window.]

Add “show_line_column”: “disabled”, to your preferences.

Copy the code from this forum post,
save it to your \Sublime Text\Packages\User folder as:
ShowLineColumn.py

Console:

reloading settings Packages/User/Preferences.sublime-settings
reloading plugin User.ShowLineColumn

And it works! Line,Column appears to the left of the Find information.

Thanks so much, OdatNerd!

0 Likes

#4

See also the following video (but in short, Tools > Developer > New Plugin... will create a stub plugin; copy the test in there and save it in the location Sublime will offer and you’re good to go).

I normally point out the video when I post one of these; apologies.

0 Likes