Home Download Buy Blog Forum Support

Display total line count

Display total line count

Postby GreyWyvern on Wed Nov 18, 2009 7:26 pm

This is just a simple thing so if it's been mentioned before my searches weren't finding it.

In the status bar where it currently says "Line ##, Column ##", can this be changed to "Line ## of ###, Column ##" where ### is the total line count for the document? It's just a handy bit of info to know at a glance :)

Cheers!
GreyWyvern
 
Posts: 106
Joined: Fri Oct 23, 2009 7:08 pm
Location: Canadia

Re: Display total line count

Postby ToddFiske on Mon Nov 23, 2009 8:48 pm

I would like to see this too, and maybe also the total byte count of the file.

Other editors I've used would even show the decimal and hex value of the current character, which would be cool to have.
ToddFiske
 
Posts: 38
Joined: Wed Nov 04, 2009 10:43 pm

Re: Display total line count

Postby GreyWyvern on Mon Nov 23, 2009 10:57 pm

ToddFiske wrote:I would like to see this too, and maybe also the total byte count of the file.

Yes, for sure! :)

ToddFiske wrote:Other editors I've used would even show the decimal and hex value of the current character, which would be cool to have.

Quite interesting! If it doesn't make the status bar look too crowded, then I say go for it.
GreyWyvern
 
Posts: 106
Joined: Fri Oct 23, 2009 7:08 pm
Location: Canadia

Re: Display total line count

Postby ToddFiske on Tue Nov 24, 2009 5:29 pm

Quite interesting! If it doesn't make the status bar look too crowded, then I say go for it.


Of course, my feature suggestion about that is to have a user editable status format with replaceable tokens:

Code: Select all
  statusFormat  "Line %line of %lines, Col %col of %cols, %bytes bytes - %char  %dec  %hex"


For example. :) Then Sublime Text can come with a default standard format, and people can customize it as they like.
ToddFiske
 
Posts: 38
Joined: Wed Nov 04, 2009 10:43 pm

Re: Display total line count

Postby EJ12N on Tue Nov 24, 2009 10:56 pm

ToddFiske wrote:
Quite interesting! If it doesn't make the status bar look too crowded, then I say go for it.


Of course, my feature suggestion about that is to have a user editable status format with replaceable tokens:

Code: Select all
  statusFormat  "Line %line of %lines, Col %col of %cols, %bytes bytes - %char  %dec  %hex"


For example. :) Then Sublime Text can come with a default standard format, and people can customize it as they like.


+1, I like that :D
even though is possible to do all this with a plugin, I would like it to be default.
EJ12N
 
Posts: 281
Joined: Tue Apr 21, 2009 5:23 pm

Re: Display total line count

Postby protoplasm on Wed Nov 25, 2009 8:24 am

I'm another one who'd appreciate line count. Also I'd quite like the encoding included[1], too! :-) I'm only generally concerned whether or not it's UTF-8 or UTF-16.

Like others I am keen to avoid a cluttered status bar, and I appreciate this could be done via a plugin but it's all about getting the best out-of-box experience. Especially when the plugins have such a steep learning curve.

[1] I know it currently shows it if you hover over the tab, but I'd certainly vote for it being ever present.
protoplasm
 
Posts: 23
Joined: Tue Oct 20, 2009 4:47 pm

Re: Display total line count

Postby gpfsmurf on Wed Nov 25, 2009 9:45 pm

As EJ12N said, you can do this via a plugin.

Here's a working sample to get you started:
Code: Select all
import sublime, sublimeplugin

class CustomStatusBar(sublimeplugin.Plugin):
   def onSelectionModified(self, view):
      if not view.hasNonEmptySelectionRegion():
         line, column = view.rowcol(view.sel()[0].begin())
         totalLines = len(view.lines(sublime.Region(0L, view.size())))
         msg = 'Line %d of %d, Column %d' % (line, totalLines, column)
         sublime.statusMessage(msg)
      else:
         sublime.statusMessage('') # restore default status msg


Or you can use something like this instead (less pretty, but more plugin friendly):
Code: Select all
view.setStatus("totalLines", "Total lines: %d" % totalLines)
gpfsmurf
 
Posts: 211
Joined: Mon Jun 23, 2008 6:31 pm

Re: Display total line count

Postby GreyWyvern on Fri Jan 22, 2010 10:19 pm

I've been using this plugin for a while and I keep finding it a bit flaky. It only shows me the line count when I change the location of the cursor, but if I switch to a different window and then switch back, it still displays the old "Line X, Column Y" message until I change the cursor location again. It also reverts after you let it sit for ten seconds or so without any interaction.

I would like to have the total line count displayed at all times. Is there a way I can also add this behaviour when the document becomes visible/selected? I am not that familiar with the event architecture for use by plugins :)

I also had to add 1 to all of the displayed values because the variables used by the plugin are all zero-based.

Code: Select all
         msg = 'Line %d of %d, Column %d' % (line + 1, totalLines + 1, column + 1)
GreyWyvern
 
Posts: 106
Joined: Fri Oct 23, 2009 7:08 pm
Location: Canadia

Re: Display total line count

Postby jps on Mon Jan 25, 2010 1:24 pm

You can see the callbacks available to plugins at http://www.sublimetext.com/docs/api-ref ... gin.Plugin , in this case you'll want to use the onActivated callback.
jps
Site Admin
 
Posts: 3071
Joined: Wed Mar 19, 2008 12:33 pm

Re: Display total line count

Postby GreyWyvern on Mon Jan 25, 2010 3:30 pm

Okay, got that working. Thanks! :) However, how do I stop the old statusbar format ("Line ##, Column ##") from returning after several seconds of no interaction? Is there a way I can interrupt that timeout?
GreyWyvern
 
Posts: 106
Joined: Fri Oct 23, 2009 7:08 pm
Location: Canadia

Next

Return to Ideas and Feature Requests

Who is online

Users browsing this forum: Yahoo [Bot] and 6 guests