[TxMt] Word Count

Hans-Jörg Bibiko bibiko at eva.mpg.de
Tue May 27 22:50:37 UTC 2008

On 28.05.2008, at 00:34, Hans-Jörg Bibiko wrote:
> On 27.05.2008, at 23:24, Mark Eli Kalderon wrote:
>> On May 27, 2008, at 10:11 PM, Jonas Steverud wrote:
>>> 20 maj 2008 kl. 20.07 skrev Patrick McElhaney:
>>>> CTRL+SHIFT+N. It's in the "Text" bundle.
>>> One should make a note though that C-S-N doesn't return the  
>>> number of characters, but the number of bytes. This is only an  
>>> issue if you use multi-byte character, which is commonly enough  
>>> to make the C-S-N command a bit broken IMHO.
> Firstly only a short answer to count Unicode characters:
> cat | ruby -e 'print STDIN.read.split(//u).size'
> input: selection or doc
> output: Show Tooltip

Maybe better:



STDIN.read.each_line { |l|
	words+=l.split(/ +/).size

puts("Bytes:      #{bytes}")
puts("Characters: #{chars}")
puts("Words:      #{words}")
puts("Lines:      #{lines}")

One could output it much more prettier ;)


More information about the textmate mailing list