Score:3

How to see the length of selected text in gedit?

ba flag

How can I see the length of selected text in gedit like this example image?

I'm using Ubuntu 22.04.

screenshot showing example

Score:2
in flag

You can do this (crudely) using the External Tools plugin. First enable the plugin: Preferences->Plugins->External Tools (check the checkbox)

Then create the following external tool with the code

#!/usr/bin/env python3

import sys
text = sys.stdin.read()
print(len(text))

set "Save" to "nothing", "input" to "current selection", and "output" to "display in bottom pane"

Then add a shortcut key of your choice. Now you can select some text, press the keybind, and get a character count of your selection in a popup at the bottom of your window.

(You can also go to (menu)->Tools->Document Statistics, but this is not very keyboard-friendly.)

You could probably also hack something together using the python console, or even write a bespoke plugin for this. With that said, I would probably just use a more customizable editor. Gedit is more meant for when you just need a text editor now and nothing else.

pers avatar
ba flag
Thanks for the answer and comments
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.