├── LICENSE ├── README.markdown ├── autoload └── litecorrect.vim └── plugin └── litecorrect.vim /LICENSE: -------------------------------------------------------------------------------- 1 | License: The MIT License (MIT) 2 | 3 | Copyright (c) 2013,2014 Reed Esau 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | 24 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | # vim-litecorrect 2 | 3 | > Lightweight auto-correction for Vim 4 | 5 | We type `teh` when we meant to type `the`. This plugin is to help us catch 6 | the most common of these typos and correct each upon hitting the space bar 7 | (or non-keyword character.) 8 | 9 | Features of this plugin: 10 | 11 | * Focused on the most common of typos 12 | * Pure Vimscript using the efficient `iabbrev` 13 | * Included auto-correct entries limited to 350 (in 2016) to ensure fast 14 | loading (see expansion policy below) 15 | * Buffer-scoped behavior (won’t touch global settings) 16 | 17 | Note that this plugin is not intended to be a replacement for the spell 18 | checker in Vim. It’s best used with spell-check enabled. 19 | 20 | ## Expansion policy 21 | 22 | Since it was created in 2013, _litecorrect_ has limited the number of 23 | default auto-correct entries (such as `teh`->`the`) to 300, avoiding the 24 | excessive load times of comparable plugins and focusing on the most common 25 | of typos. 26 | 27 | Meanwhile, the adoption of new disk technologies reduces the penalty we 28 | pay when initializing plugins. This provides _litecorrect_ an opportunity 29 | to grow while not significantly impacting load-time performance. 30 | 31 | Henceforth, _litecorrect_ will expand by up to 50 entries each year. For 32 | 2016 it will grow to 350 entries. For 2017, 400 entries, and so on. 33 | 34 | ## Requirements 35 | 36 | May require a recent version of Vim. 37 | 38 | ## Installation 39 | 40 | You can install _litecorrect_ using a Vim package manager, such as 41 | [Vundle][vnd], [Plug][plg], or [Pathogen][pth]. If you are using a recent 42 | verion of vim or neovim, you can also install using native package support. 43 | (See [:help packages][packages].) 44 | 45 | [vnd]: https://github.com/gmarik/Vundle.vim 46 | [plg]: https://github.com/junegunn/vim-plug 47 | [pth]: https://github.com/tpope/vim-pathogen 48 | [packages]: https://vimhelp.org/repeat.txt.html#packages 49 | 50 | ## Configuration 51 | 52 | Because you may not want auto-corrections in all file types you edit, you can 53 | configure this plugin per file type. For example, to enable litecorrect support 54 | in `markdown` and `textile` files, place in your `.vimrc`: 55 | 56 | ```vim 57 | set nocompatible 58 | filetype plugin on " may already be in your .vimrc 59 | 60 | augroup litecorrect 61 | autocmd! 62 | autocmd FileType markdown,mkd call litecorrect#init() 63 | autocmd FileType textile call litecorrect#init() 64 | augroup END 65 | ``` 66 | 67 | Optionally, you can build on the defaults by providing your own corrections. 68 | Note that the corrections are stored as key-value entries where the value is 69 | a list of the common misspellings for the key. 70 | 71 | ``` 72 | let user_dict = { 73 | \ 'maybe': ['mabye'], 74 | \ 'medieval': ['medival', 'mediaeval', 'medevil'], 75 | \ 'then': ['hten'], 76 | \ } 77 | augroup litecorrect 78 | autocmd! 79 | autocmd FileType markdown call litecorrect#init(user_dict) 80 | autocmd FileType textile call litecorrect#init(user_dict) 81 | augroup END 82 | ``` 83 | 84 | The corrections you provide will be in addition to the defaults. Where 85 | there’s a conflict, your correction will prevail. 86 | 87 | ### Correct previous misspelling 88 | 89 | To augment _litecorrect_ you may find the following key mapping useful. 90 | It forces the top-ranked correction on the first misspelled word 91 | before the cursor. 92 | 93 | Add to your `.vimrc` with a key mapping of your choice: 94 | 95 | ```vim 96 | nnoremap [s1z= 97 | inoremap u[s1z=`]Au 98 | ``` 99 | 100 | It generates a fresh undo point prior to the correction so 101 | that you can conveniently undo if necessary. 102 | 103 | Note that _litecorrect_ does not map any keys. 104 | 105 | ### Typographic characters 106 | 107 | By default, straight quotes will be used in corrections. For example: 108 | 109 | ``` 110 | Im -> I'm 111 | shouldnt -> shouldn't 112 | thats -> that's 113 | ``` 114 | 115 | If you prefer typographic (“curly”) quotes, install an educating quote plugin 116 | like [vim-textobj-quote][qu] that will automatically transform straight quotes 117 | to curly ones in your typing, including your corrections. For example: 118 | 119 | ``` 120 | I'm -> I’m 121 | shouldn't -> shouldn’t 122 | that's -> that’s 123 | ``` 124 | 125 | ## Criteria to add (or modify) default entries 126 | 127 | Note that the number of default entries will be limited for fast loading. See 128 | policy above. 129 | 130 | Suggestions for improving the defaults are welcome, but good evidence is needed 131 | that a suggested auto-correct entry adds value to the list. 132 | 133 | ## Related projects 134 | 135 | If load time performance isn’t an issue, you can seek a more comprehensive 136 | approach: 137 | 138 | * [wordlist.vim](https://github.com/vim-scripts/wordlist.vim) - nearly 800 entries 139 | * [vim-autocorrect](https://github.com/panozzaj/vim-autocorrect) - over 12K entries! 140 | 141 | An alternative that builds on [tpope/vim-abolish][va]: 142 | 143 | * [vim-correction](https://github.com/jdelkins/vim-correction) - approx. 700 entries 144 | 145 | [va]: https://github.com/tpope/vim-abolish 146 | 147 | ## See also 148 | 149 | If you find this plugin useful, you may want to check out these others 150 | originally by [@reedes][re]: 151 | 152 | * [vim-colors-pencil][cp] - color scheme for Vim inspired by IA Writer 153 | * [vim-lexical][lx] - building on Vim’s spell-check and thesaurus/dictionary completion 154 | * [vim-pencil][pn] - rethinking Vim as a tool for writers 155 | * [vim-textobj-quote][qu] - extends Vim to support typographic (‘curly’) quotes 156 | * [vim-textobj-sentence][ts] - improving on Vim's native sentence motion command 157 | * [vim-thematic][th] - modify Vim’s appearance to suit your task and environment 158 | * [vim-wheel][wh] - screen-anchored cursor movement for Vim 159 | * [vim-wordy][wo] - uncovering usage problems in writing 160 | * [vim-wordchipper][wc] - power tool for shredding text in Insert mode 161 | 162 | [re]: https://github.com/reedes 163 | [cp]: https://github.com/preservim/vim-colors-pencil 164 | [lx]: https://github.com/preservim/vim-lexical 165 | [vo]: https://github.com/preservim/vim-one 166 | [pn]: https://github.com/preservim/vim-pencil 167 | [ts]: https://github.com/preservim/vim-textobj-sentence 168 | [qu]: https://github.com/preservim/vim-textobj-quote 169 | [th]: https://github.com/preservim/vim-thematic 170 | [wh]: https://github.com/preservim/vim-wheel 171 | [wo]: https://github.com/preservim/vim-wordy 172 | [wc]: https://github.com/preservim/vim-wordchipper 173 | 174 | ## Future development 175 | 176 | If you’ve spotted a problem or have an idea on improving this plugin, 177 | please post it to the [GitHub project issue page][issues]. 178 | 179 | [issues]: https://github.com/preservim/vim-litecorrect/issues 180 | -------------------------------------------------------------------------------- /autoload/litecorrect.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================ 2 | " File: litecorrect.vim 3 | " Description: autoload functions for vim-litecorrect plugin 4 | " Maintainer: preservim 5 | " Created: January 20, 2014 6 | " License: The MIT License (MIT) 7 | " ============================================================================ 8 | 9 | scriptencoding utf-8 10 | 11 | if exists("autoloaded_litecorrect") 12 | finish 13 | endif 14 | let autoloaded_litecorrect = 1 15 | 16 | function! s:unicode_enabled() 17 | return &encoding == 'utf-8' 18 | endfunction 19 | 20 | function! litecorrect#init(...) 21 | 22 | ia Iam I am 23 | ia Im I'm 24 | ia TEh The 25 | ia THat That 26 | ia THe The 27 | ia Teh The 28 | ia Theyare They are 29 | ia Youre You're 30 | ia abotu about 31 | ia aboutit about it 32 | ia acn can 33 | ia adn and 34 | ia aer are 35 | ia agian again 36 | ia ahev have 37 | ia ahve have 38 | ia alos also 39 | ia alot a lot 40 | ia alse else 41 | ia alsot also 42 | ia amde made 43 | ia amke make 44 | ia amkes makes 45 | ia anbd and 46 | ia andd and 47 | ia anf and 48 | ia ans and 49 | ia aobut about 50 | ia aslo also 51 | ia asthe as the 52 | ia atthe at the 53 | ia awya away 54 | ia aywa away 55 | ia bakc back 56 | ia baout about 57 | ia bcak back 58 | ia beacuse because 59 | ia becuase because 60 | ia bve be 61 | ia cant can't 62 | ia chaneg change 63 | ia chanegs changes 64 | ia chekc check 65 | ia chnage change 66 | ia chnaged changed 67 | ia chnages changes 68 | ia claer clear 69 | ia cmo com 70 | ia cna can 71 | ia coudl could 72 | ia cpoy copy 73 | ia dael deal 74 | ia didnot did not 75 | ia didnt didn't 76 | ia diea idea 77 | ia doens does 78 | ia doese does 79 | ia doesnt doesn't 80 | ia doign doing 81 | ia doimg doing 82 | ia donig doing 83 | ia dont don't 84 | ia eahc each 85 | ia efel feel 86 | ia ehlp help 87 | ia ehr her 88 | ia emial email 89 | ia ened need 90 | ia enxt next 91 | ia esle else 92 | ia ew we 93 | ia eyar year 94 | ia eyt yet 95 | ia fatc fact 96 | ia fidn find 97 | ia fiel file 98 | ia firts first 99 | ia flase false 100 | ia fo of 101 | ia fomr form 102 | ia fora for a 103 | ia forthe for the 104 | ia foudn found 105 | ia frmo from 106 | ia fro for 107 | ia frome from 108 | ia fromthe from the 109 | ia fwe few 110 | ia gerat great 111 | ia gievn given 112 | ia goign going 113 | ia gonig going 114 | ia gruop group 115 | ia grwo grow 116 | ia haev have 117 | ia hasa has a 118 | ia havea have a 119 | ia hda had 120 | ia hge he 121 | ia hlep help 122 | ia holf hold 123 | ia hsa has 124 | ia hsi his 125 | ia htan than 126 | ia htat that 127 | ia hte the 128 | ia htem them 129 | ia hten then 130 | ia htere there 131 | ia htese these 132 | ia htey they 133 | ia hting thing 134 | ia htink think 135 | ia htis this 136 | ia hvae have 137 | ia hvaing having 138 | ia hvea have 139 | ia hwich which 140 | ia hwo how 141 | ia idae idea 142 | ia idaes ideas 143 | ia ihs his 144 | ia ina in a 145 | ia inot into 146 | ia inteh in the 147 | ia inthe in the 148 | ia inthese in these 149 | ia inthis in this 150 | ia inwhich in which 151 | ia isthe is the 152 | ia isze size 153 | ia itis it is 154 | ia itwas it was 155 | ia iused used 156 | ia iwll will 157 | ia iwth with 158 | ia jstu just 159 | ia jsut just 160 | ia knwo know 161 | ia knwon known 162 | ia knwos knows 163 | ia konw know 164 | ia konwn known 165 | ia konws knows 166 | ia kwno know 167 | ia laod load 168 | ia lastr last 169 | ia layed laid 170 | ia liek like 171 | ia liekd liked 172 | ia liev live 173 | ia likly likely 174 | ia ling long 175 | ia liuke like 176 | ia loev love 177 | ia lsat last 178 | ia lveo love 179 | ia lvoe love 180 | ia mcuh much 181 | ia mear mere 182 | ia mial mail 183 | ia mkae make 184 | ia mkaes makes 185 | ia mkea make 186 | ia moeny money 187 | ia mroe more 188 | ia msut must 189 | ia muhc much 190 | ia muts must 191 | ia mysefl myself 192 | ia myu my 193 | ia nad and 194 | ia niether neither 195 | ia nkow know 196 | ia nkwo know 197 | ia nmae name 198 | ia nowe now 199 | ia nto not 200 | ia nver never 201 | ia nwe new 202 | ia nwo now 203 | ia ocur occur 204 | ia ofa of a 205 | ia ofits of its 206 | ia ofthe of the 207 | ia oging going 208 | ia ohter other 209 | ia omre more 210 | ia oneof one of 211 | ia onthe on the 212 | ia onyl only 213 | ia ot to 214 | ia otehr other 215 | ia otu out 216 | ia outof out of 217 | ia owrk work 218 | ia owuld would 219 | ia paide paid 220 | ia peice piece 221 | ia puhs push 222 | ia pwoer power 223 | ia rela real 224 | ia rulle rule 225 | ia rwite write 226 | ia sasy says 227 | ia seh she 228 | ia shoudl should 229 | ia sitll still 230 | ia sleect select 231 | ia smae same 232 | ia smoe some 233 | ia sned send 234 | ia soem some 235 | ia sohw show 236 | ia soze size 237 | ia stnad stand 238 | ia stpo stop 239 | ia syas says 240 | ia ta at 241 | ia tahn than 242 | ia taht that 243 | ia tath that 244 | ia teh the 245 | ia tehir their 246 | ia tehn then 247 | ia tehre there 248 | ia tehy they 249 | ia tghe the 250 | ia tghis this 251 | ia thanit than it 252 | ia thansk thanks 253 | ia thast that 254 | ia thats that's 255 | ia thatthe that the 256 | ia theh then 257 | ia theri their 258 | ia theyare they are 259 | ia thgat that 260 | ia thge the 261 | ia thier their 262 | ia thign thing 263 | ia thme them 264 | ia thn then 265 | ia thna than 266 | ia thne then 267 | ia thnig thing 268 | ia thre there 269 | ia thsi this 270 | ia thsoe those 271 | ia thta that 272 | ia thyat that 273 | ia thye they 274 | ia ti it 275 | ia tiem time 276 | ia tihs this 277 | ia timne time 278 | ia tiome time 279 | ia tje the 280 | ia tjhe the 281 | ia tkae take 282 | ia tkaes takes 283 | ia tkaing taking 284 | ia todya today 285 | ia tothe to the 286 | ia towrad toward 287 | ia tthe the 288 | ia ture true 289 | ia twpo two 290 | ia tyhat that 291 | ia tyhe the 292 | ia tyhe they 293 | ia uise use 294 | ia untill until 295 | ia veyr very 296 | ia vrey very 297 | ia waht what 298 | ia wass was 299 | ia watn want 300 | ia weas was 301 | ia wehn when 302 | ia werre were 303 | ia whcih which 304 | ia wherre where 305 | ia whic which 306 | ia whihc which 307 | ia whn when 308 | ia whta what 309 | ia wih with 310 | ia wihch which 311 | ia wiht with 312 | ia willbe will be 313 | ia willk will 314 | ia witha with a 315 | ia withe with 316 | ia withh with 317 | ia withit with it 318 | ia witht with 319 | ia withthe with the 320 | ia witn with 321 | ia wiull will 322 | ia wnat want 323 | ia wnats wants 324 | ia woh who 325 | ia wohle whole 326 | ia wokr work 327 | ia woudl would 328 | ia wrod word 329 | ia wroet wrote 330 | ia wrok work 331 | ia wtih with 332 | ia wuould would 333 | ia wya way 334 | ia yaer year 335 | ia yera year 336 | ia yoiu you 337 | ia yoru your 338 | ia youare you are 339 | ia youre you're 340 | ia youve you've 341 | ia yrea year 342 | ia ytou you 343 | ia yuo you 344 | ia yuor your 345 | 346 | " user overrides 347 | let l:user_dict = a:0 ? a:1 : {} 348 | for l:item in items(l:user_dict) 349 | let l:fixed = l:item[0] 350 | for l:subitem in l:item[1] 351 | execute 'ia ' . l:subitem . ' ' . l:fixed 352 | endfor 353 | endfor 354 | endfunction 355 | -------------------------------------------------------------------------------- /plugin/litecorrect.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================= 2 | " File: plugin/litecorrect.vim 3 | " Description: lightweight autocorrection for Vim 4 | " Maintainer: perservim 5 | " Created: January 20, 2014 6 | " License: The MIT License (MIT) 7 | " ============================================================================= 8 | 9 | if exists('g:loaded_litecorrect') || &cp | finish | endif 10 | let g:loaded_litecorrect = 1 11 | 12 | " Save 'cpoptions' and set Vim default to enable line continuations. 13 | let s:save_cpo = &cpo 14 | set cpo&vim 15 | 16 | let &cpo = s:save_cpo 17 | unlet s:save_cpo 18 | " vim:ts=2:sw=2:sts=2 19 | 20 | --------------------------------------------------------------------------------