Alert the amount of characters in the current selection
-
-
Save dralletje/c90995adc1d45f12ed3c to your computer and use it in GitHub Desktop.
Backtick Example Command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Just copied this from the web somewhere */ | |
const word_count = word => | |
word | |
.replace(/(^\s*)|(\s*$)/gi,"") | |
.replace(/[ ]{2,}/gi," ") | |
.replace(/\n /,"\n") | |
.split(' ').length | |
var selection = window.getSelection().toString() | |
var chars = selection.length | |
var words = word_count(selection) | |
alert(chars + " characters, " + word + " words."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Count characters/words", | |
"description": "Count the amount of characters/words in your selection.", | |
"icon": "https://backtickio.s3.amazonaws.com/icons/backtick.png", | |
"link": "http://google.com" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment