How to exclude code from spell-checking in LyX?

I'm writing a technical document in LyX (version for Windows) and I'm using Hunspell for spell checking.

Throughout the text, there are code snippets which I've formatted with the "Code" text style (from the "Logical Markup" module). Obviously, most of these snippets are not valid German, so every single code snippet has a dotted red line (see screenshot).

How to exclude code from spell-checking in LyX?

Is there a way to tell Hunspell to ignore all text formatted as code?


Yes, the idea is to add a local version of the Logical Markup module. Here are the steps below for LyX 2.1, which should be released in a couple of days.

  1. Locate the Logical Markup module: Go to Help > About and under "Library directory:" you will see a path such as /usr/share/lyx/ (this is what shows up on Ubuntu). In that folder, there is a folder "layouts" and inside that there is a file named "logicalmkup.module".
  2. Locate your user directory: Go to Help > About and it will show you. On Linux it is under ~/.lyx. Inside that directory there is a folder "layouts". Copy the file you found above, "logicalmkup.module", to this "layouts" directory.
  3. Customize that module. Open it up and add spellcheck 0 to the part relating to the "code" inset.
  4. Start LyX and go to Tools > Reconfigure.
  5. Restart LyX.

For more information, see Help > Customization. Below I give the relevant part of the file after adding the spellcheck (after step 3). Note that for you it might be different on 2.0.5. Do not just copy what I post here because the formats are different. I just provide it to show how and where to add the line.

InsetLayout Flex:Code
    LyxType               charstyle
    LabelString           code
    LatexType             command
    LatexName             code
      Family              Typewriter
    InToc                 true
    HTMLTag               code
    spellcheck            0
    ResetsFont true

Category: lyx Time: 2014-04-15 Views: 1
Tags: code lyx spelling

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C), All Rights Reserved.

processed in 0.224 (s). 12 q(s)