Giter Club home page Giter Club logo

vim-autocorrect's Introduction

General Information:

Author: Anthony Panozzo

Contact: [email protected]

Script URL: http://www.vim.org/scripts/script.php?script_id=2429

License: GPL

Detailed description:

Looking through the examples in Vim, there are examples of correcting typos and misspellings like:

iabbrev teh the
iabbrev het the
...

However, it is time-consuming to create this list by hand. You also have to enter the correct capitalization, which is a pain. ('teh->the' will not work for 'Teh->The')

I found a nice list from Wikipedia and cleaned it up a bit as a basis, and incorporated the typo fixes from Vim Cream. I also added some words that I commonly misspelled or mistyped, and have taken additional contributions from users of the script.

I'm sure there are some mistakes, or common mistakes that aren't in here yet, so if you find any, please contact me and I will gladly change things. There are some additional details or thoughts as well as a shortcut to a word-processing mode at http://www.panozzaj.com/blog/2008/11/06/vim-word-processing

There is a GitHub repository that you can contribute to at http://github.com/panozzaj/vim-autocorrect/tree/master

Install details:

This plugin works with Vundle and Pathogen out of the box and so this is the recommended method of installation. However, if you do not want to use Vundle or Pathogen, download the .tar file, and add autocorrect.vim to the 'plugin' folder in your .vim directory.

The plugin does not load all the correction mappings automatically, as this slows down Vim's startup time by at least one second which is often annoying. Instead, you can type:

:call AutoCorrect()

inside Vim to load the corrections.

If you want to automatically load the corrections for certain filetypes, you can put something like this in your .vimrc file (example is for .txt files):

autocmd filetype text call AutoCorrect()

If you want to load the corrections all the time, and can bear waiting one second every time you use Vim, put this in your .vimrc:

call AutoCorrect()

Troubleshooting

If you are getting the following error:

E117: Unknown function: AutoCorrect

You might check that you have the plugin loaded with your Vim bundler of choice before invoking the AutoCorrect function automatically, or invoke it manually. For more details, see this issue.

General thoughts

Currently Vim has no built-in way to correct multiple words, so doing something like 'a a->a' is not possible. There is a file in the GitHub repository that contains some of these in case there ever comes an easy way to do this.

My philosophy on contributions is to take only the ones that I could reasonably see a sober person making on a qwerty keyboard who is in a hurry. So if there are random characters in there, it's not likely going to make it in. That should capture 95% of errors, since most are due to spelling errors or transpositions.

If there is a questionable correction, I consult Google. Slightly antiquated words will be left as-is. If the left side is correct already, I won't add that correction. If something is close to two words, I will take the more common one, or just leave out the correction.

I've thought about adding ones like (c)->©, but it's not clear to me how many people would benefit from this. So I guess in general, my philosophy is to make the changes that will help most of the people most of the time.

Contributions

Thanks to Duncan de Wet (duncannz) for turning this into a Vundler/Pathogen style plugin and making some improvements.

Thanks to Igor Dvorkin (@idvorkin) for adding a guard to ensure the plugin is only loaded once.

vim-autocorrect's People

Contributors

duncannz avatar idvorkin avatar panozzaj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vim-autocorrect's Issues

cannot call AutoCorrect in vimrc

I installed the plugin, really great tool! Calling AutoCorrect() after launching vim had no problem, but When I put call AutoCorrect() into .vimrc, it keeps warning me

Error detected while processing /Users/laike9m/.vimrc:
line   52:
E117: Unknown function: AutoCorrect
Press ENTER or type command to continue

Here's my .vimrc file, everything is OK if I remove the last line which is call AutoCorrect().

set nocompatible              " be iMproved
filetype off                  " required!
set nu
syntax on                     " 开启语法高亮
set fileencodings=utf-8,gbk   " 解决中文编码问题
set backspace=indent,eol,start " 保证退格键可以正常工作
set noswapfile                " 不产生swp文件
set autoread                  " 文件变化时可以实时刷新
set hlsearch                  " 高亮搜索文本
set omnifunc=syntaxcomplete#Complete " omni-complete

:set shiftwidth=4 tabstop=4
autocmd FileType html setlocal shiftwidth=2 tabstop=2
:set modifiable
:colorscheme desert

filetype plugin indent on     " required!

set rtp+=~/.vim/bundle/vundle/ " Vundle setting
call vundle#rc()
" let Vundle manage Vundle
Bundle 'gmarik/vundle'

" My bundles here:
Bundle 'scrooloose/nerdtree'
let NERDTreeShowHidden=1
let NERDTreeShowBookmarks=1                 " 显示书签
let NERDTreeIgnore=['\.\.$', '\.$', '\~$']  " 不显示.和..路径
Bundle 'jistr/vim-nerdtree-tabs'
Bundle 'klen/python-mode'
Bundle 'panozzaj/vim-autocorrect'

" set font
if has("gui_running")
    if has("gui_gtk2")
        set lines=999 columns=999     " Linux 最大化窗口
        set guifont=Inconsolata\ 12
    elseif has("gui_macvim")
        set guifont=Menlo\ Regular:h14
    elseif has("gui_win32")
        set rtp+=~/vimfiles/bundle/vundle/ " Vundle setting
        let path='~/vimfiles/bundle'
        call vundle#rc(path)
        au GUIEnter * simalt ~x       " Windows 最大化窗口
        set guifont=Consolas:h11:cANSI
    endif
endif

call AutoCorrect()

Thank you!

Regexp support

Is it possible to auto correct something like

import Whatever form `whatever`

to

import Whatever from `whatever`

I keep typing form all the time, so some sort of regexp like this

:%s/\vimport\s+(\w+)\s+form/import \1 from/g

Would help

No out-of-the box Vundle/Pathogen compatibility

To allow vim-autocorrect to work with Vundle or Pathogen without any changes to vim config, there is only one simple change that needs to be made: move autocorrect.vim to a new directory called plugin. This would make vim-autocorrect useful to those who simply want their plugins to work without making any extra changes to their configuration.

However, this slows down the start up time of vim quite considerably and this is the major disadvantage of the plugin overall. The only way to fix this I can see would be to cut down on less-used mappings.

I am wondering what your thoughts are on this, 3 years from the last repo activity (I don't think Vundle was around 3 years ago 😄)

EDIT: I notice that the repo vim-scripts/autocorrect.vim already has the above change of putting the autocorrect.vim file in a directory called plugin. Not sure why the two repos are different.

[wishlist] option to source external wordlist

it'd be great if there was a way to source an external wordlist to your plugin where I can define my own word definitions. This behaviour would allow me to create a seperated collection of words so I could later on propose them as pull request alltogether. In Ultisnips for example you are able to integrate your own snippets through the global variable

let g:UltiSnipsSnippetDirectories= ["yoursnippets"]

with pointing to ~/.vim/yoursnippets. I'd be really satisfied to see something similar in a future version of your plugin, if doable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.