sponsor Vim development Vim logo Vim Book Ad

vim-langtool : list and jump to grammar errors found by LanguageTool

 script karma  Rating 3/3, Downloaded by 505  Comments, bugs, improvements  Vim wiki

created by
Enno Nagel
script type
This Vim plug-in collects all grammar mistakes (of the currently open file)
found by LanguageTool (https://languagetool.org) into the quickfix (or local)
list from which they can be jumped to.


If you already have LanguageTool installed and start it in the command line by
an executable, say /usr/bin/langtool, then add to your vimrc the line

  let g:langtool_cmd = '/usr/bin/langtool'

Otherwise, download and unpack LanguageTool from
https://languagetool.org/download/, say into the folder ~/LanguageTool, and add
to your vimrc the line

  let g:langtool_jar = '~/LanguageTool/languagetool-commandline.jar'

where the right-hand side, ~/LanguageTool/languagetool-commandline.jar, is the
path of the file languagetool-commandline.jar.


The command


populates the location-list with all grammar mistakes found by LanguageTool.
The (location-list) window that lists them can then be opened by :lwindow and
they can be jumped to by :lN respectively :lp. (Have a look at vim-unimpaired
    to use convenient mappings instead).

LanguageTool runs in the background by Vim's job feature, provided a custom
:Make command exists, such as

- that of vim-dispatch, or
- with AsyncRun.vim installed (see also Hints below), that defined by

    command! -bang -nargs=* -complete=file Make AsyncRun<bang> -auto=make -program=make -strip <args>

The (quickfix) window that lists the grammar mistakes can then be opened by
:cwindow and they can be jumped to by :cN respectively :cp.

To automatically open the location-list window after LangTool, add autocmd
QuickFixCmdPost lmake lwindow to your vimrc, respectively autocmd
QuickFixCmdPost make cwindow if the :Make command exists. To automatically run
LangTool after saving the modifications to a text, mail or markdown file, add
to your vimrc:

    autocmd FileType text,mail,markdown autocmd BufWrite <buffer=abuf> LangTool


Command-line parameters can be passed to LanguageTool by the global variable
g:langtool_parameters and the buffer-local variable b:langtool_parameters. By

let g:langtool_parameters = ''


let b:langtool_parameters = '--autoDetect'

For example, the mother tongue can be set and (categories of) rules enabled and
disabled by adding to your vimrc

  let s:enablecategories = 'CREATIVE_WRITING,WIKIPEDIA' .

  let g:langtool_parameters = ' --mothertongue de' .
        \ ' --enablecategories ' . s:enablecategories .
        \ ' --enable ' . s:enable .
        \ ' --disable ' . s:disable

:LangTool sets the language that LanguageTool will use to that used by Vim to
spellcheck by

  let b:langtool_parameters = '--language ' . &l:spelllang

To avoid that the file is saved before LanguageTool checks it for mistakes,

  let g:langtool_save = 0


If you use AsyncRun.vim, add let g:asyncrun_trim = 1 to your vimrc to avoid
empty lines in the quickfix list. Other options, such as g:asyncrun_save might
be of interest.


This Vim plug-in is simpler than vim-LanguageTool and vim-grammarous. In
particular, it lets Vim parse the LanguageTool output to stdout via an
appropriate value of &errorformat; see :help errorformat. (Whereas both
plug-ins implement their proper parser for the deprecated XML output format
of LanguageTool.)


vim-langtool is developed at https://github.com/Konfekt/vim-langtool where issues can be filed.

install details
Unzip vim-langtool.zip into  ~/.vim on Linux and MacOS, or into %USERPROFILE%\vimfiles on Windows.

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
vim-langtool.zip 1.5 2024-03-15 7.0 Enno Nagel trigger slow check for language tool languages only when necessary
vim-langtool.zip 1.4 2021-12-19 7.0 Enno Nagel improve spelllang detection and Microsoft Windows support
vim-langtool.zip 1.3 2021-03-04 7.0 Enno Nagel fix detection and installation instructions
vim-langtool.zip 1.2 2020-04-06 7.0 Enno Nagel round up some rough edges
vim-langtool.zip 1.1 2020-01-12 7.0 Enno Nagel propose to save buffer to file if need be and show autodetected language
vim-langtool.zip 1.0 2020-01-08 7.0 Enno Nagel Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
Vim at Github