Skip to content

is there any way to toogle case? #213

Answered by ousia
ousia asked this question in Q&A
Jun 10, 2022 · 2 comments · 7 replies
Discussion options

You must be logged in to vote

@rgieseke, this works fine:

keys['ctrl+alt+u'] = function()
  if Upper_Case then
    buffer.lower_case()
    Upper_Case = false
  else
    buffer.upper_case()
    Upper_Case = true
  end
end

I realized I was modifying a backup init.lua (so my approach couldn’t work at all 😅).

It seems that for Lua if x is nil, x is both not true and not false.

if UpperCase then print("yes") else print("no") end

if UpperCase == true then print("yes") else print("no") end

if UpperCase == false then print("yes") else print("no") end

if not UpperCase then print("yes") else print("no") end

The first three conditionals print no, the fourth one prints yes.

This did the trick here.

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
4 replies
@ousia
Comment options

@rgieseke
Comment options

@ousia
Comment options

@rgieseke
Comment options

Comment options

You must be logged in to vote
3 replies
@rgieseke
Comment options

@rgieseke
Comment options

@ousia
Comment options

Answer selected by ousia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants