# Word Count

> Editor42 Word Count plugin — tracks and displays word count, character count, and character count without spaces.

Source: https://editor42.com/plugins/wordcount  
Every page of editor42.com has a Markdown copy at its URL + `.md` (`index.md` after a URL that ends in `/`); all of them are in one file: https://editor42.com/llms-full.txt

Plugin alias: `wordcount`

```js
editor42.init({
  plugins: 'wordcount'
});
```

Tracks and displays word count, character count, and character count without spaces for both the full document and the current selection. Fires periodic count updates in response to content changes and provides a dialog with all counts.

## Commands

| Command | Description |
|---|---|
| `editor42WordCount` | Opens the Word Count dialog. |

## Toolbar buttons

| Button | Type | Description |
|---|---|---|
| `wordcount` | Button | Opens the Word Count dialog. |

## Menu items

| Item | Description |
|---|---|
| `wordcount` | Opens the Word Count dialog. |

## Events

| Event | Description |
|---|---|
| `wordCountUpdate` | Fired when counts are recalculated. Payload: `{ wordCount: { words, characters, charactersWithoutSpaces } }`. |

## API

| Method | Description |
|---|---|
| `body.getWordCount()` | Returns word count for the full document. |
| `body.getCharacterCount()` | Returns character count for the full document. |
| `body.getCharacterCountWithoutSpaces()` | Returns character count without spaces for the full document. |
| `selection.getWordCount()` | Returns word count for the current selection. |
| `selection.getCharacterCount()` | Returns character count for the current selection. |
| `selection.getCharacterCountWithoutSpaces()` | Returns character count without spaces for the current selection. |
| `getCount()` | Deprecated. Returns body word count. Use `body.getWordCount()` instead. |
