Kakoune: Case insensitive search

Created on 9 Mar 2017  路  2Comments  路  Source: mawww/kakoune

I wondered how to do a case insensitive search with /. I found out without much trouble that it could be done by using a regex like (?i)something.

I haven't seen it in the perl regex syntax link provided in kakoune documentation (my poor of ability to read the doc?). I thought it might be worth documenting it more explicitly, given it's a relatively common need.

Most helpful comment

Here is the relevant bit from the documentation:

Modifiers
(?imsx-imsx ... ) alters which of the perl modifiers are in effect within the pattern, changes take effect from the point that the block is first seen and extend to any enclosing ). Letters before a '-' turn that perl modifier on, letters afterward, turn it off.
(?imsx-imsx:pattern) applies the specified modifiers to pattern only.

I have the following bindings in my configuration:

map -docstring 'case insensitive search' global user '/' /(?i)
map -docstring 'case insensitive backward search' global user '<a-/>' <a-/>(?i)
map -docstring 'case insensitive extend search' global user '?' ?(?i)
map -docstring 'case insensitive backward extend-search' global user '<a-?>' <a-?>(?i)

Maybe this could be written in the wiki or something.

All 2 comments

Here is the relevant bit from the documentation:

Modifiers
(?imsx-imsx ... ) alters which of the perl modifiers are in effect within the pattern, changes take effect from the point that the block is first seen and extend to any enclosing ). Letters before a '-' turn that perl modifier on, letters afterward, turn it off.
(?imsx-imsx:pattern) applies the specified modifiers to pattern only.

I have the following bindings in my configuration:

map -docstring 'case insensitive search' global user '/' /(?i)
map -docstring 'case insensitive backward search' global user '<a-/>' <a-/>(?i)
map -docstring 'case insensitive extend search' global user '?' ?(?i)
map -docstring 'case insensitive backward extend-search' global user '<a-?>' <a-?>(?i)

Maybe this could be written in the wiki or something.

Yep, case insensitive search is done by adding (?i) in the regex, and can be automated as shown by @lenormf.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lenormf picture lenormf  路  4Comments

alexherbo2 picture alexherbo2  路  4Comments

lenormf picture lenormf  路  4Comments

basbebe picture basbebe  路  4Comments

abitofalchemy picture abitofalchemy  路  3Comments