If you regularly need to count the words in text that you are composing or otherwise managing, then there are several approaches for doing this. A common one is to simply copy whatever text you are interested in and paste it in a Word or Pages document, and then use the word counting features in there to count your words; however, if you find yourself doing this frequently then you can create a special service for counting words.
To do this, open Automator on your Mac and create a new Service workflow, then perform the following steps to set it up:
- Ensure the service receives selected “text” in “any application” using the topmost menus.
- Drag the “Run Shell Script” action to the workflow and change the “pass input” option to be “as arguments.”
echo Words: echo $1 | wc -w echo Characters: echo $1 | wc -c
- Drag the “Set Value of Variable” action to the workflow and choose “New Variable” from its drop-down menu. Give this variable some unique name like “returnedText.” You should see this variable appear in the variable list below the workflow.
- Drag the “Ask for Confirmation” action to the workflow
- Drag the “returnedText” variable from the variable list to the confirmation action’s title area (you might not be able to drag it to the message area).
When finished, save the workflow with a name like “Word Count” and you should be good to go. Now simply select text in any application, and then right-click it and choose the Word Count service from the contextual menu (it may be in a “Services” submenu) and you will see a message pop up with the number of words and characters in your selection.
In addition to accessing this from the Services menu, you can go to the Keyboard Shortcuts section of the Keyboard system preferences, and locate the new service in the “Services” category. Then select it and click the “Add Shortcut” button to give it a unique hotkey of your choosing. I recommend using something like Shift-Control-Option-W, or another hotkey with more than two modifiers in it, to ensure it is unique.