{"id":13479706,"url":"https://github.com/preservim/vim-pencil","last_synced_at":"2025-04-08T08:14:47.893Z","repository":{"id":12965013,"uuid":"15643444","full_name":"preservim/vim-pencil","owner":"preservim","description":"Rethinking Vim as a tool for writing","archived":false,"fork":false,"pushed_at":"2023-04-03T18:16:21.000Z","size":517,"stargazers_count":1625,"open_issues_count":41,"forks_count":39,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-04-01T05:34:31.700Z","etag":null,"topics":["asciidoc","markdown","prose","restructured-text","textile","vim","vim-plugin","writing"],"latest_commit_sha":null,"homepage":"","language":"Vim Script","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/preservim.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2014-01-05T01:32:32.000Z","updated_at":"2025-03-31T22:56:18.000Z","dependencies_parsed_at":"2024-01-14T16:07:44.050Z","dependency_job_id":"d0807ddf-189c-43a2-8a44-3e8b694f74b1","html_url":"https://github.com/preservim/vim-pencil","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preservim%2Fvim-pencil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preservim%2Fvim-pencil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preservim%2Fvim-pencil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preservim%2Fvim-pencil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/preservim","download_url":"https://codeload.github.com/preservim/vim-pencil/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247801169,"owners_count":20998339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asciidoc","markdown","prose","restructured-text","textile","vim","vim-plugin","writing"],"created_at":"2024-07-31T16:02:21.740Z","updated_at":"2025-04-08T08:14:47.868Z","avatar_url":"https://github.com/preservim.png","language":"Vim Script","funding_links":[],"categories":["Vim Script","plugins for writing","Vim script"],"sub_categories":[],"readme":"# vim-pencil\n\n[![Vint](https://github.com/reedes/vim-pencil/workflows/Vint/badge.svg)](https://github.com/reedes/vim-pencil/actions?workflow=Vint)\n\n\u003e Rethinking Vim as a tool for writers\n\n\u003cbr/\u003e\n\n- - -\n![demo](https://i.imgur.com/0KYl5vU.gif)\n- - -\n\n# Features\n\nThe _pencil_ plugin aspires to make Vim as powerful a tool for writers as\nit is for coders by focusing narrowly on the handful of tweaks needed to\nsmooth the path to writing prose.\n\n* For editing prose-oriented file types such as _text_, _markdown_,\n  _mail_, _rst_, _tex_, _textile_, and _asciidoc_\n* Agnostic on soft line wrap _versus_ hard line breaks, supporting both\n* Auto-detects wrap mode via `modeline` and sampling\n* Adjusts navigation key mappings to suit the wrap mode\n* Creates undo points on common punctuation during Insert mode, including\n  deletion via line `\u003cC-U\u003e` and word `\u003cC-W\u003e`\n* Buffer-scoped configuration (with a few minor exceptions, _pencil_ preserves\n  your global settings)\n* Support for Vim’s Conceal feature to hide markup defined by Syntax plugins\n  (e.g., `_` and `*` markup for styled text in \\_*Markdown*\\_)\n* Support for display of mode indicator (`␍` and `⤸`, e.g.) in the status line\n* Pure Vimscript with no dependencies\n\nIn addition, when using hard line break mode:\n\n* Makes use of Vim’s powerful autoformat while inserting text, except for\n  tables and code blocks where you won’t want it.\n* *NEW* Optional key mapping to suspend autoformat for the Insert.\n\nNeed spell-check, distraction-free editing, and other features? Vim is about\ncustomization. To complete your editing environment, learn to configure Vim and\ndraw upon its rich ecosystem of plugins.\n\n# Why use Vim for writing?\n\nWith plenty of word processing applications available, including those\nthat specifically cater to writers, why use a modal editor like Vim?\nSeveral reasons have been offered:\n\n* Your hands can rest in a neutral ‘home’ position, only rarely straying\n  to reach for mouse, track pad, or arrow keys\n* Minimal chording, with many mnemonic-friendly commands\n* Sophisticated capabilities for navigating and manipulating text\n* Highly configurable, enabling you to build a workflow that suits your\n  needs, with many great plugins available\n* No proprietary format lock-in\n\nBut while such reasons might be sound, they remain scant justification to\nswitch away from the familiar word processor. Instead, you need\na compelling reason—one that can appeal to a writer’s love for language\nand the tools of writing.\n\nYou can find that reason in Vim’s mysterious command sequences. Take `cas`\nfor instance. You might see it as a mnemonic for _Change Around Sentence_\nto replace an existing sentence. But dig a bit deeper to discover that\nsuch commands have a grammar of their own, comprised of nouns, verbs, and\nmodifiers. Think of them as the composable building blocks of a _domain\nspecific language_ for manipulating text, one that can become a powerful\ntool in expressing yourself. For more details on vi-style editing, see...\n\n* [Learn to speak vim – verbs, nouns, and modifiers!][ls] (December 2011)\n* [Your problem with Vim is that you don’t grok vi][gv] (December 2011)\n* [Intro to Vim’s Grammar][ig] (January 2013)\n* [Why Atom Can’t Replace Vim, Learning the lesson of vi][wa] (March 2014)\n* [Language of Vim/Neovim][lovn] (January 2015)\n\n[ls]: https://yanpritzker.com/2011/12/16/learn-to-speak-vim-verbs-nouns-and-modifiers/\n[gv]: https://stackoverflow.com/a/1220118/\n[ig]: https://takac.github.io/2013/01/30/vim-grammar/\n[wa]: https://medium.com/p/433852f4b4d1\n[lovn]: https://allsyed.com/posts/language-of-vim-neovim/\n\n# Installation\n\nYou can install using your favorite Vim package manager. (E.g.,\n[Pathogen][pathogen], [Vundle][vundle], or [Plug][plug].) If you are using\na recent version of vim or neovim, you can also use native package\nsupport. (See [:help packages][packages].)\n\n_For those new to Vim: before installing this plugin, consider getting\ncomfortable with the basics of Vim by working through one of the many\ntutorials available._\n\n[pathogen]: https://github.com/tpope/vim-pathogen\n[vundle]: https://github.com/VundleVim/Vundle.vim\n[plug]: https://github.com/junegunn/vim-plug\n[packages]: https://vimhelp.org/repeat.txt.html#packages\n\n# Configuration\n\n## Initializing by command\n\nYou can manually enable, disable, and toggle _pencil_ as a command:\n\n* `Pencil` - initialize _pencil_ with auto-detect for the current buffer\n* `NoPencil` (or `PencilOff`) - removes navigation mappings and restores buffer to global settings\n* `TogglePencil` (or `PencilToggle`) - if on, turns off; if off, initializes with auto-detect\n\nBecause auto-detect might not work as intended, you can invoke a command\nto set the behavior for the current buffer:\n\n* `SoftPencil` (or `PencilSoft`) - initialize _pencil_ with soft line wrap mode\n* `HardPencil` (or `PencilHard`) - initialize _pencil_ with hard line break mode (and Vim’s autoformat)\n\n## Initializing by file type\n\nInitializing _pencil_ by file type is _optional_, though doing so will\nautomatically set up your buffers for editing prose.\n\nAdd support for your desired file types to your `.vimrc`:\n\n```vim\nset nocompatible\nfiletype plugin on       \" may already be in your .vimrc\n\naugroup pencil\n  autocmd!\n  autocmd FileType markdown,mkd call pencil#init()\n  autocmd FileType text         call pencil#init()\naugroup END\n```\n\nYou can initialize several prose-oriented plugins together:\n\n```vim\naugroup pencil\n  autocmd!\n  autocmd FileType markdown,mkd call pencil#init()\n                            \\ | call lexical#init()\n                            \\ | call litecorrect#init()\n                            \\ | call textobj#quote#init()\n                            \\ | call textobj#sentence#init()\naugroup END\n```\n\nFor a list of other prose-oriented plugins, consult the [See\nalso](#see-also) section below.\n\n## Hard line breaks or soft line wrap?\n\nCoders will have the most experience with the former, and writers the\nlatter. But whatever your background, chances are that you must contend\nwith both conventions. This plugin doesn’t force you to choose a side—you\ncan configure each buffer independently.\n\nIn most cases you can set a default to suit your preference and let\nauto-detection figure out what to do.\n\n```vim\nlet g:pencil#wrapModeDefault = 'soft'   \" default is 'hard'\n\naugroup pencil\n  autocmd!\n  autocmd FileType markdown,mkd call pencil#init()\n  autocmd FileType text         call pencil#init({'wrap': 'hard'})\naugroup END\n```\n\nIn the example above, for buffers of type `markdown` this plugin will\nauto-detect the line wrap approach, with soft line wrap as the default.\n\nFor buffers of type `text`, it will initialize with hard line breaks,\neven if auto-detect might suggest soft line wrap.\n\n## Automatic formatting\n\n_The ‘autoformat’ feature affects `HardPencil` (hard line break) mode\nonly._\n\nWhen inserting text while in `HardPencil` mode, Vim’s powerful autoformat\nfeature will be _enabled_ by default and can offer many of the same\nbenefits as soft line wrap.\n\nTo set the default behavior in your `.vimrc`:\n\n```vim\nlet g:pencil#autoformat = 1      \" 0=disable, 1=enable (def)\n```\n\nYou can override this default during initialization, as in:\n\n```vim\naugroup pencil\n  autocmd!\n  autocmd FileType markdown call pencil#init({'wrap': 'hard', 'autoformat': 1})\n  autocmd FileType text     call pencil#init({'wrap': 'hard', 'autoformat': 0})\n  ...\naugroup END\n```\n\n...where buffers of type `markdown` and `text` will use hard line breaks,\nbut `text` buffers will have autoformat disabled.\n\n## Suspend automatic formatting for the Insert\n\nThere are two useful exceptions where autoformat (when enabled for the\nbuffer) will be _temporarily disabled_ for the current Insert:\n\n**First** is _pencil’s_ ‘blacklisting’ feature: if used with popular\nprose-oriented syntax plugins, _pencil_ will suspend autoformat when you\nenter Insert mode from inside a code block or table.\n\n**Second**, where blacklisting falls short, you can optionally map\na buffer-scoped ‘modifier’ key to suspend autoformat during the next\nInsert:\n\n```vim\nlet g:pencil#map#suspend_af = 'K'   \" default is no mapping\n```\n\nUsing the above mapping, with `Ko` you’ll enter Insert mode with the\ncursor on a new line, but autoformat will suspend for that Insert. Using\n`o` by itself will retain autoformat.\n\nBy default no modifier key is mapped.\n\n(See the advanced section below for details on how blacklisting is\nimplemented and configured).\n\n## Manual formatting\n\nNote that you need not rely on Vim’s autoformat exclusively and can\nmanually reformat paragraphs with standard Vim commands:\n\n* `gqap` - format current paragraph (see `:help gq` for details)\n* `vapJgqap` - merge two paragraphs (current and next) and format\n* `ggVGgq` or `:g/^/norm gqq` - format all paragraphs in buffer\n\nOptionally, you can map these operations to underutilized keys in your\n`.vimrc`:\n\n```vim\nnnoremap \u003csilent\u003e Q gqap\nxnoremap \u003csilent\u003e Q gq\nnnoremap \u003csilent\u003e \u003cleader\u003eQ vapJgqap\n```\n\nOr you may wish to ‘unformat’, (i.e., remove hard line breaks) when using\nsoft line wrap.\n\n* `vipJ` - join all lines in current paragraph\n* `:%norm vipJ` - unformat all paragraphs in buffer\n\n## Default textwidth\n\nYou can configure the textwidth to be used in `HardPencil` (hard line\nbreak) mode when no textwidth is set globally, locally, or available via\nmodeline. It defaults to `74`, but you can change that value in your\n`.vimrc`:\n\n```vim\nlet g:pencil#textwidth = 74\n```\n\n## Sentence spacing\n\nBy default, when formatting text (through `gwip`, e.g.) only one space\nwill be inserted after a period(`.`), exclamation point(`!`), or question\nmark(`?`). You can change this default:\n\n```vim\nlet g:pencil#joinspaces = 0     \" 0=one_space (def), 1=two_spaces\n```\n\n## Cursor wrap\n\nBy default, `h`/`l` and the left/right cursor keys will move to the\nprevious/next line after reaching first/last character in a line with\na hard break. If you wish to retain the default Vim behavior, set the\n`cursorwrap` value to `0` in your `.vimrc`:\n\n```vim\nlet g:pencil#cursorwrap = 1     \" 0=disable, 1=enable (def)\n```\n\n## Concealing \\_\\_markup\\_\\_\n\n_pencil_ enables Vim’s powerful Conceal feature, although support among\nSyntax and Colorscheme plugins is currently spotty.\n\nYou can change _pencil’s_ default settings for conceal in your `.vimrc`:\n\n```vim\nlet g:pencil#conceallevel = 3     \" 0=disable, 1=one char, 2=hide char, 3=hide all (def)\nlet g:pencil#concealcursor = 'c'  \" n=normal, v=visual, i=insert, c=command (def)\n```\n\nFor more details on Vim’s Conceal feature, see:\n\n```vim\n:help conceallevel\n:help concealcursor\n```\n\n### Concealing styled text in Markdown\n\nSyntax plugins such as [tpope/vim-markdown][tm] support concealing the\nmarkup characters when displaying \\_*italic*\\_, \\*\\*__bold__\\*\\*, and\n\\*\\*\\*___bold italic___\\*\\*\\* styled text.\n\nTo use Vim’s Conceal feature with Markdown, you will need to install:\n\n1. [tpope/vim-markdown][tm] as it’s currently the only Markdown syntax\n   plugin that supports conceal.\n\n2. A monospaced font (such as [Cousine][co]) featuring the _italic_,\n   **bold**, and ***bold italic*** style variant for styled text.\n\n3. A colorscheme (such as [preservim/vim-colors-pencil][cp]) which supports\n   the Markdown-specific highlight groups for styled text.\n\nYou should then only see the `_` and `*` markup for the cursor line and in\nvisual selections.\n\n**Terminal users:** consult your terminal’s documentation to configure your\nterminal to support **bold** and _italic_ styles.\n\n[co]: https://fonts.google.com/specimen/Cousine\n[tm]: https://github.com/tpope/vim-markdown\n\n## Status line indicator\n\nYour status line can reflect the wrap mode for _pencil_ buffers. For\nexample, `␍` to represent `HardPencil` (hard line break) mode.  To\nconfigure your status line and ruler, add to your `.vimrc`:\n\n```vim\nset statusline=%\u003c%f\\ %h%m%r%w\\ \\ %{PencilMode()}\\ %=\\ col\\ %c%V\\ \\ line\\ %l\\,%L\\ %P\nset rulerformat=%-12.(%l,%c%V%)%{PencilMode()}\\ %P\n```\n\nor if using [bling/vim-airline][va]:\n\n```vim\nlet g:airline_section_x = '%{PencilMode()}'\n```\n\nThe default indicators now include ‘auto’ for when Vim’s autoformat is\nactive in hard line break mode. (If autoformat is suspended for the\nInsert, it’ll show the ‘hard’ indicator.)\n\n```vim\nlet g:pencil#mode_indicators = {'hard': 'H', 'auto': 'A', 'soft': 'S', 'off': '',}\n```\n\nIf Unicode is detected, the default indicators are:\n\n```vim\nlet g:pencil#mode_indicators = {'hard': '␍', 'auto': 'ª', 'soft': '⤸', 'off': '',}\n```\n\nIf you don’t like the default indicators, you can specify your own in\nyour `.vimrc`.\n\nNote that `PencilMode()` will return blank for buffers in which _pencil_\nhas not been initialized.\n\n[va]: https://github.com/bling/vim-airline\n\n## Advanced pencil\n\n### Advanced initialization\n\nYou may want to refactor initialization statements into a function in\nyour `.vimrc` to set up a buffer for writing:\n\n```vim\nfunction! Prose()\n  call pencil#init()\n  call lexical#init()\n  call litecorrect#init()\n  call textobj#quote#init()\n  call textobj#sentence#init()\n\n  \" manual reformatting shortcuts\n  nnoremap \u003cbuffer\u003e \u003csilent\u003e Q gqap\n  xnoremap \u003cbuffer\u003e \u003csilent\u003e Q gq\n  nnoremap \u003cbuffer\u003e \u003csilent\u003e \u003cleader\u003eQ vapJgqap\n\n  \" force top correction on most recent misspelling\n  nnoremap \u003cbuffer\u003e \u003cc-s\u003e [s1z=\u003cc-o\u003e\n  inoremap \u003cbuffer\u003e \u003cc-s\u003e \u003cc-g\u003eu\u003cEsc\u003e[s1z=`]A\u003cc-g\u003eu\n\n  \" replace common punctuation\n  iabbrev \u003cbuffer\u003e -- –\n  iabbrev \u003cbuffer\u003e --- —\n  iabbrev \u003cbuffer\u003e \u003c\u003c «\n  iabbrev \u003cbuffer\u003e \u003e\u003e »\n\n  \" open most folds\n  setlocal foldlevel=6\n\n  \" replace typographical quotes (reedes/vim-textobj-quote)\n  map \u003csilent\u003e \u003cbuffer\u003e \u003cleader\u003eqc \u003cPlug\u003eReplaceWithCurly\n  map \u003csilent\u003e \u003cbuffer\u003e \u003cleader\u003eqs \u003cPlug\u003eReplaceWithStraight\n\n  \" highlight words (reedes/vim-wordy)\n  noremap \u003csilent\u003e \u003cbuffer\u003e \u003cF8\u003e :\u003cC-u\u003eNextWordy\u003ccr\u003e\n  xnoremap \u003csilent\u003e \u003cbuffer\u003e \u003cF8\u003e :\u003cC-u\u003eNextWordy\u003ccr\u003e\n  inoremap \u003csilent\u003e \u003cbuffer\u003e \u003cF8\u003e \u003cC-o\u003e:NextWordy\u003ccr\u003e\n\nendfunction\n\n\" automatically initialize buffer by file type\nautocmd FileType markdown,mkd,text call Prose()\n\n\" invoke manually by command for other file types\ncommand! -nargs=0 Prose call Prose()\n```\n\nFor highly-granular control, you can override _pencil_ and other configuration\nsettings when initializing buffers by file type:\n\n```vim\naugroup pencil\n  autocmd!\n  autocmd FileType markdown,mkd call pencil#init()\n                            \\ | call litecorrect#init()\n                            \\ | setl spell spl=en_us fdl=4 noru nonu nornu\n                            \\ | setl fdo+=search\n  autocmd Filetype git,gitsendemail,*commit*,*COMMIT*\n                            \\   call pencil#init({'wrap': 'hard', 'textwidth': 72})\n                            \\ | call litecorrect#init()\n                            \\ | setl spell spl=en_us et sw=2 ts=2 noai\n  autocmd Filetype mail         call pencil#init({'wrap': 'hard', 'textwidth': 60})\n                            \\ | call litecorrect#init()\n                            \\ | setl spell spl=en_us et sw=2 ts=2 noai nonu nornu\n  autocmd Filetype html,xml     call pencil#init({'wrap': 'soft'})\n                            \\ | call litecorrect#init()\n                            \\ | setl spell spl=en_us et sw=2 ts=2\naugroup END\n```\n\nConfigurable options for `pencil#init()` include: `autoformat`,\n`concealcursor`, `conceallevel`, `cursorwrap`, `joinspaces`, `textwidth`,\nand `wrap`. These are detailed above.\n\n### Autoformat manual control\n\n_The ‘autoformat’ feature affects `HardPencil` (hard line break) mode\nonly._\n\nTo suspend autoformat for the next Insert, see above.\n\nWhen you need to manually enable/disable autoformat for the current\nbuffer, you can do so with a command:\n\n* `PFormat` - enable autoformat for buffer (can still be disabled via blacklisting)\n* `PFormatOff` - disable autoformat for buffer\n* `PFormatToggle` - toggle to enable if disabled, etc.\n\nYou can map a key in your `.vimrc` to toggle Vim’s autoformat:\n\n```vim\nnoremap \u003csilent\u003e \u003cF7\u003e :\u003cC-u\u003ePFormatToggle\u003ccr\u003e\ninoremap \u003csilent\u003e \u003cF7\u003e \u003cC-o\u003e:PFormatToggle\u003ccr\u003e\n```\n\n### Autoformat blacklisting (and whitelisting)\n\n_The ‘autoformat’ feature affects `HardPencil` (hard line break) mode\nonly._\n\nWhen editing formatted text, such as a table or code block, Vim’s\nautoformat will wreak havoc with the formatting. In these cases you will\nwant autoformat suspended for the duration of the Insert.\n\nWhen entering Insert mode, _pencil_ will determine the highlight group at\nthe cursor position. If that group has been blacklisted, _pencil_ will\nsuspend autoformat for the Insert. For example, if editing a buffer of\ntype ‘markdown’, autoformat will be suspended if you invoke Insert mode\nfrom inside a `markdownFencedCodeBlock` highlight group.\n\nBlacklists are now declared by file type. The default blacklists (and\nwhitelists) are declared in the `plugin/pencil.vim` module. Here’s an\nexcerpt showing the configuration for the ‘markdown’ file type:\n\n```vim\n  let g:pencil#autoformat_config = {\n        \\   'markdown': {\n        \\     'black': [\n        \\       'htmlH[0-9]',\n        \\       'markdown(Code|H[0-9]|Url|IdDeclaration|Link|Rule|Highlight[A-Za-z0-9]+)',\n        \\       'markdown(FencedCodeBlock|InlineCode)',\n        \\       'mkd(Code|Rule|Delimiter|Link|ListItem|IndentCode)',\n        \\       'mmdTable[A-Za-z0-9]*',\n        \\     ],\n        \\     'white': [\n        \\      'markdown(Code|Link)',\n        \\     ],\n        \\   },\n        [snip]\n        \\ }\n```\n\nThe whitelist will override the blacklist and enable Vim’s autoformat if\ntext that would normally be blacklisted doesn’t dominate the entire line.\nThis allows autoformat to work with `inline` code and links.\n\n### Auto-detecting wrap mode\n\nIf you didn’t explicitly specify a wrap mode during initialization,\n_pencil_ will attempt to detect it.\n\nIt will first look for a `textwidth` (or `tw`) specified in a modeline.\nFailing that, _pencil_ will then sample lines from the start of the\nbuffer.\n\n#### Detect via modeline\n\nWill the wrap mode be detected accurately? Maybe. But you can improve its\nchances by giving _pencil_ an explicit hint.\n\nAt the bottom of this document is a odd-looking code:\n\n```html\n\u003c!-- vim: set tw=73 :--\u003e\n```\n\nThis is an **optional** ‘modeline’ that tells Vim to run the following\ncommand upon loading the file into a buffer:\n\n```vim\n:set textwidth=73\n```\n\nIt tells _pencil_ to assume hard line breaks, regardless of whether or\nnot soft line wrap is the default editing mode for buffers of type\n‘markdown’.\n\nYou explicitly specify soft wrap mode by specifying a textwidth of `0`:\n\n```html\n\u003c!-- vim: set tw=0 :--\u003e\n```\n\nNote that if the modelines feature is disabled (such as for security\nreasons) the textwidth will still be set by this plugin.\n\n#### Detect via sampling\n\nIf no modeline with a textwidth is found, _pencil_ will sample the\ninitial lines from the buffer, looking for those excessively-long.\n\nThere are two settings you can add to your `.vimrc` to tweak this behavior.\n\nThe maximum number of lines to sample from the start of the buffer:\n\n```vim\nlet g:pencil#softDetectSample = 20\n```\n\nSet that value to `0` to disable detection via line sampling.\n\nWhen the number of bytes on a sampled line per exceeds this next value,\nthen _pencil_ assumes soft line wrap.\n\n```vim\nlet g:pencil#softDetectThreshold = 130\n```\n\nIf no such lines found, _pencil_ falls back to the default wrap mode.\n\n# See also\n\n* [To Vim][tv] - Writer and psychologist Ian Hocking on using Vim for writing\n* [Vim Training Class - Basic motions and commands][tc] - video tutorial by Shawn Biddle\n* [Vim for Writers][vw] - guide to the basics geared to writers\n\nBloggers and developers discuss _pencil_ and its brethern:\n\n* [Reed Esau’s growing list of Vim plugins for writers][regl] (2014) - by @pengwynn\n* [Distraction Free Writing in Vim][dfwiv] (2014) - by @tlattimore\n* [Safari Blog: Turning vim into an IDE through vim plugins][tviai] (2014) - by @jameydeorio\n* [Quick tops for writing prose with Vim][qtfwp] (2014) - by @benoliver999\n* [UseVim: Reed Esau’s Writing Plugins][rewp] (2015) - by @alexyoung\n* [Tomasino Labs: Vim in Context][vic] (2015) - by @jamestomasino\n\nOther plugins of specific interest to writers:\n\n* [danielbmarques/vim-ditto][vd] - highlight repeated words\n* [tpope/vim-abolish][ab] - search for, substitute, and abbr. multiple variants of a word\n* [tommcdo/vim-exchange][ex] - easy text exchange operator for Vim\n* [junegunn/limelight.vim][jl] - focus mode that brightens current paragraph\n* [junegunn/goyo.vim][jg] - distraction-free editing mode\n\n[vd]: https://github.com/danielbmarques/vim-ditto\n[qtfwp]: https://benoliver999.com/technology/2014/12/06/vimforprose/\n[vic]: https://labs.tomasino.org/vim-in-context/\n[rewp]: https://medium.com/usevim/reed-esaus-writing-plugins-5b6c65bc808f\n[tviai]: https://www.safaribooksonline.com/blog/2014/11/23/way-vim-ide/\n[regl]: http://wynnnetherland.com/journal/reed-esau-s-growing-list-of-vim-plugins-for-writers/\n[dfwiv]: http://tlattimore.com/blog/distraction-free-writing-in-vim/\n[ab]: https://github.com/tpope/vim-abolish\n[ex]: https://github.com/tommcdo/vim-exchange\n[jl]: https://github.com/junegunn/limelight.vim\n[jg]: https://github.com/junegunn/goyo.vim\n\nMarkdown syntax plugins\n\nMarkdown users typically won’t need to install a syntax plugin unless\nthey want the latest version of Pope’s syntax highlighting:\n\n* [tpope/vim-markdown][tvm] - (recommended) the latest version of Pope’s\n  syntax plugin which ships with Vim\n\nThose using tables and footnotes should consider installing this plugin:\n\n* [mattly/vim-markdown-enhancements][mvme]\n\nAlternatives to Tim Pope’s syntax highlighting include:\n\n* [preservim/vim-markdown][pvm]\n* [gabrielelana/vim-markdown][gvm]\n\nNote that the plasticboy and gabrielelana plugins may incorrectly\nreformat bulleted lists when Vim’s autoformat is active in _pencil_’s\nHardPencil mode.\n\n[tvm]: https://github.com/tpope/vim-markdown\n[pvm]: https://github.com/preservim/vim-markdown\n[gvm]: https://github.com/gabrielelana/vim-markdown\n[mvme]: https://github.com/mattly/vim-markdown-enhancements\n\nIf you find the _pencil_ plugin useful, check out these others originally\nby [@reedes][re]:\n\n* [vim-colors-pencil][cp] - color scheme for Vim inspired by IA Writer\n* [vim-lexical][lx] - building on Vim’s spell-check and thesaurus/dictionary completion\n* [vim-litecorrect][lc] - lightweight auto-correction for Vim\n* [vim-textobj-quote][qu] - extends Vim to support typographic (‘curly’) quotes\n* [vim-textobj-sentence][ts] - improving on Vim’s native sentence motion command\n* [vim-thematic][th] - modify Vim’s appearance to suit your task and environment\n* [vim-wheel][wh] - screen-anchored cursor movement for Vim\n* [vim-wordy][wo] - uncovering usage problems in writing\n* [vim-wordchipper][wc] - power tool for shredding text in Insert mode\n\nUnimpressed by _pencil_? [vim-pandoc][vp] offers prose-oriented features\nwith its own Markdown variant.\n\n[cp]: https://github.com/preservim/vim-colors-pencil\n[lc]: https://github.com/preservim/vim-litecorrect\n[lx]: https://github.com/preservim/vim-lexical\n[qu]: https://github.com/preservim/vim-textobj-quote\n[re]: https://github.com/reedes\n[tc]: https://www.youtube.com/watch?v=Nim4_f5QUxA\n[th]: https://github.com/preservim/vim-thematic\n[ts]: https://github.com/preservim/vim-textobj-sentence\n[tv]: https://ianhocking.com/2013/11/17/to-vim/\n[vo]: https://github.com/preservim/vim-one\n[vw]: https://therandymon.com/woodnotes/vim-for-writers/vimforwriters.html\n[wh]: https://github.com/preservim/vim-wheel\n[wo]: https://github.com/preservim/vim-wordy\n[wc]: https://github.com/preservim/vim-wordchipper\n[vp]: https://github.com/vim-pandoc/vim-pandoc\n\n# Future development\n\nIf you’ve spotted a problem or have an idea on improving _pencil_, please\nreport it [as an issue][issues], or better yet submit [a pull\nrequest][pull-request].\n\n[issues]: https://github.com/preservim/vim-pencil/issues\n[pull-request]: https://github.com/preservim/vim-pencil/pulls\n\n\u003c!-- vim: set tw=73 :--\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpreservim%2Fvim-pencil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpreservim%2Fvim-pencil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpreservim%2Fvim-pencil/lists"}