1

LanguageToolCheck and LanguageToolClean are 2 commands used in vim-languageTool plugin.

LanguageToolCheck command check and list out spelling errors of your text. And LanguageToolClear will clean the error list. During error checking mode. User then can use :lne to jump to the next error. I wonder how to map the n to :lne command when LanguageToolCheck command is executed and map back to normal function (jump to next highlighted) for n when LanguageToolClear is executed

1 Answer 1

2

This is not exactly what you asked for, but well known plugin vim-unimpaired by Tim Pope adds short mappings for many commands, including :lnext which is the one you're after.

The vim-unimpaired mappings generally use [ and ] as its direction ("previous" vs "next", or "on" vs "off") followed by a single letter to identify the object (l for the location list.)

So you have ]l for :lnext.

]l is not as short as just using n, but it might be something for you to consider, since it doesn't involve changing the behavior of n during an operation (it's quite possible you'll end up wanting to search in between LanguageToolCheck and LanguageToolClear.) You may also find the other mappings from vim-unimpaired to be quite useful, it's definitely among the plug-ins I tend to recommend.

2
  • Thanks a lot fibranden, it would be so cool to have some sort of smart n that can detect the user intentions to search the coc-diagonostic-next if using the vim-coc, search the next spelling error when using LanguageToolCheck and search for the next highlight if highlight set is true. I would like to getting to know vim better and write a plugin for that
    – SLN
    Nov 9, 2020 at 23:58
  • 2
    @SLN Go for it! If you want to learn vimscript this is one of the most highly regarded guides available: learnvimscriptthehardway.stevelosh.com
    – B Layer
    Nov 10, 2020 at 7:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.