sponsor Vim development Vim logo Vim Book Ad

SpellLangIdentifier : Automatically identify buffer's language and set the spell lang

 script karma  Rating 13/4, Downloaded by 2181  Comments, bugs, improvements  Vim wiki

created by
Douglas Augusto
 
script type
utility
 
description
SpellLangIdentifier detects the language based on the buffer contents through 'mguesser' (http://www.mnogosearch.org/guesser/), which in turn uses "N-Gram-Based Text Categorization".

Git repository: https://github.com/daaugusto/spelllangidentifier
 
install details
Installation
------------

Decompress the tarball and change to directory sli-x.y.z/
From there, assuming you have a standard Vim setup:


   mkdir -p ~/.vim/plugin
   cp -r SpellLangIdentifier.vim LanguageIdentifier.sh mguesser ~/.vim/plugin
   cp vimrc.sample ~/.vimrc.sli
   cd ~/.vim/plugin/mguesser && make



Configuration (~/.vimrc)
------------------------

Please, check out the sample Vim configuration file which you have just copied. If you prefer you can introduce your changes there and source it directly from your personal vimrc (usually ~/.vimrc), by inserting the line:

   source ~/.vimrc.sli

Make sure you remove or comment out any previous spell checking configuration that might conflict with the new ones.


Usage
-----

   1. Automatically (just open a text, mail or TeX file, as illustrated in ~/.vimrc.sli). It even works on-the-fly while you edit the file, switching the languages on a paragraph basis when working on multi-language documents (configurable).
   2. Using shortcuts in normal or insert mode (F5, F6, F7 and F8; F9 to disable spell checking and on-the-fly language identification).
   3. Directly: :{range}SpellLangIdentify (identify the language based on {range} lines; default is the whole buffer).


Notes
-----

The user can create its own reference language set ("maps") which will guide/bias the language identification. An example would be to create an n-gram frequency file (a map) for words related to the medical literature or, perhaps, to some subset of the English language. Please check out mguesser's documentation for that.


Prerequisites
-------------

   * Unix-like environment (POSIX shell, coreutils, awk, sed, grep, file, ...).

   * In order to improve language detection according to the file type at hand, it is recommended (but not required) to have the following utilities installed: detex, ps2ascii, html2text.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
sli-1.0.1.tar.gz 1.0.1 2020-07-04 7.0 Douglas Augusto OS X compatibility changes (thanks Ingo Heimbach).
sli-1.0.0.tar.gz 1.0.0 2015-06-07 7.0 Douglas Augusto * Fixes the issue with stray characters in console-based Vim when using on-the-fly language detection.
* Better error handling.
* Improves the sample configuration file.

sli-0.4.1.tar.gz 0.4.1 2014-08-29 7.0 Douglas Augusto Mail file types were not being handled/filtered properly and a note about a known issue in console-based Vim when using on-the-fly language detection.
sli-0.4.0.tar.gz 0.4.0 2014-07-29 7.0 Douglas Augusto Improved mappings (see README and vimrc.sample), better support according to the file type, bug fixes.
sli-0.3.0.tar.gz 0.3.0 2014-07-25 7.0 Douglas Augusto Fine-grained on-the-fly spell language identification and bug fixes.
sli-0.2.0.tar.gz 0.2.0 2014-07-23 7.0 Douglas Augusto Improvements, bug fixes and clarifications.
sli-0.1.0.tar.gz 0.1.0 2014-07-21 7.0 Douglas Augusto Initial upload
ip used for rating: 216.73.216.4

Questions about Vim should go to the maillist. Help Uganda.     Vim at Github