mirror of
https://github.com/preservim/vim-litecorrect.git
synced 2025-11-09 02:13:47 -05:00
first cut
This commit is contained in:
23
LICENSE.markdown
Normal file
23
LICENSE.markdown
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
License: The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2013,2014 Reed Esau
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
||||||
|
<!-- vim: set tw=74 :-->
|
||||||
98
README.markdown
Normal file
98
README.markdown
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
# vim-litecorrect
|
||||||
|
|
||||||
|
> Lightweight auto-correction for Vim
|
||||||
|
|
||||||
|
We type `teh` when we meant to type `the`. This plugin is to help us catch
|
||||||
|
the most common of these typos and correct each upon hitting the space
|
||||||
|
bar.
|
||||||
|
|
||||||
|
Features of this plugin:
|
||||||
|
|
||||||
|
* Focused on the most common of typos that we make
|
||||||
|
* Uses Vim’s `iabbrev`
|
||||||
|
* Buffer-scoped
|
||||||
|
* User-extendable
|
||||||
|
|
||||||
|
Note that this plugin is not a replacement for teh spell checker in Vim.
|
||||||
|
|
||||||
|
This plugin defines the most common typos we make along with their corrections:
|
||||||
|
|
||||||
|
```
|
||||||
|
let g:litecorrect#defaults =
|
||||||
|
\{'I' : ['i'],
|
||||||
|
\ 'The' : ['TEh', 'Teh'],
|
||||||
|
\ 'that' : ['htat'],
|
||||||
|
\ 'the' : ['hte', 'teh'],
|
||||||
|
\ 'this' : ['htis'],
|
||||||
|
\ 'then' : ['tehn'],
|
||||||
|
\ 'what' : ['waht'],
|
||||||
|
\}
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that the corrections are the keys, with the misspellings for each stored
|
||||||
|
in a list.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
May require a recent version of Vim.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Install using Pathogen, Vundle, Neobundle, or your favorite Vim package
|
||||||
|
manager.
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
Because you may not want auto-corrections in all file types you edit, you can
|
||||||
|
configure this plugin per file type. For example, to enable litecorrect support
|
||||||
|
in `markdown` and `textile` files, place in your `.vimrc`:
|
||||||
|
|
||||||
|
```vim
|
||||||
|
augroup litecorrect
|
||||||
|
autocmd!
|
||||||
|
autocmd FileType markdown call litecorrect#init()
|
||||||
|
autocmd FileType textile call litecorrect#init()
|
||||||
|
augroup END
|
||||||
|
```
|
||||||
|
|
||||||
|
Alternatively, you can build on the defaults by provide your own corrections:
|
||||||
|
|
||||||
|
```
|
||||||
|
let user_dict = {
|
||||||
|
\ 'maybe': ['mabye'],
|
||||||
|
\ 'medieval': ['medival', 'mediaeval', 'medevil'],
|
||||||
|
\ 'then': ['hten'],
|
||||||
|
\ }
|
||||||
|
augroup litecorrect
|
||||||
|
autocmd!
|
||||||
|
autocmd FileType markdown call litecorrect#init(user_dict)
|
||||||
|
augroup END
|
||||||
|
```
|
||||||
|
|
||||||
|
The corrections you provide will be in addition to those in those in
|
||||||
|
`g:litecorrect#defaults`. Where there’s a conflict, your correction will
|
||||||
|
prevail.
|
||||||
|
|
||||||
|
## Criteria to add to defaults
|
||||||
|
|
||||||
|
Suggestions for adding to the defaults are welcome, but good evidence is
|
||||||
|
needed that they are common typos.
|
||||||
|
|
||||||
|
## See also
|
||||||
|
|
||||||
|
For a more comprehensive approach, check out
|
||||||
|
[vim-autocorrect](https://github.com/panozzaj/vim-autocorrect).
|
||||||
|
|
||||||
|
If you like this plugin, you may like these other ones from the same author:
|
||||||
|
|
||||||
|
* [vim-quotable](http://github.com/reedes/vim-quotable) - extends Vim to
|
||||||
|
support typographic (‘curly’) quotes
|
||||||
|
* [vim-writer](http://github.com/reedes/vim-writer) - Extending Vim to better
|
||||||
|
support writing prose and documentation
|
||||||
|
|
||||||
|
## Future development
|
||||||
|
|
||||||
|
If you have any ideas on improving this plugin, please post them to the github
|
||||||
|
project issue page.
|
||||||
|
|
||||||
|
<!-- vim: set tw=74 :-->
|
||||||
43
plugin/litecorrect.vim
Normal file
43
plugin/litecorrect.vim
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
" ============================================================================
|
||||||
|
" File: litecorrect.vim
|
||||||
|
" Description: vim-litecorrect plugin
|
||||||
|
" Maintainer: Reed Esau <github.com/reedes>
|
||||||
|
" Last Change: December 29, 2013
|
||||||
|
" License: The MIT License (MIT)
|
||||||
|
" ============================================================================
|
||||||
|
|
||||||
|
scriptencoding utf-8
|
||||||
|
|
||||||
|
if exists('g:loaded_litecorrect') || &cp | finish | endif
|
||||||
|
let g:loaded_litecorrect = 1
|
||||||
|
|
||||||
|
" Save 'cpoptions' and set Vim default to enable line continuations.
|
||||||
|
let s:save_cpo = &cpo
|
||||||
|
set cpo&vim
|
||||||
|
|
||||||
|
" a dictionary of the most common of typos
|
||||||
|
let g:litecorrect#defaults =
|
||||||
|
\{'I' : ['i'],
|
||||||
|
\ 'The' : ['TEh', 'Teh'],
|
||||||
|
\ 'that' : ['htat'],
|
||||||
|
\ 'the' : ['hte', 'teh'],
|
||||||
|
\ 'this' : ['htis'],
|
||||||
|
\ 'then' : ['tehn'],
|
||||||
|
\ 'what' : ['waht'],
|
||||||
|
\}
|
||||||
|
|
||||||
|
function! litecorrect#init(...)
|
||||||
|
let l:user_dict = a:0 ? a:1 : {}
|
||||||
|
for l:dict in [ g:litecorrect#defaults, l:user_dict ]
|
||||||
|
for l:item in items( l:dict )
|
||||||
|
let l:fixed = l:item[0]
|
||||||
|
for l:subitem in l:item[1]
|
||||||
|
execute 'ia <buffer> ' . l:subitem . ' ' . l:fixed
|
||||||
|
endfor
|
||||||
|
endfor
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
let &cpo = s:save_cpo
|
||||||
|
unlet s:save_cpo
|
||||||
|
" vim:ts=2:sw=2:sts=2
|
||||||
Reference in New Issue
Block a user