tags:

views:

60

answers:

2

I added following line of code in .vimrc

let g:jslint_status = 'enabled'

if exists("jslint_status")
  echo jstlint_status
else
  echo 'not found'
endif

Error message

E121: Undefined variable: jstlint_status
E15: Invalid expression: jstlint_status

What am I doing wrong?

+2  A: 

Double-check your spelling. You're checking if jslint_statusexists, but you're echoing jstlint_status. Notice that extra T - the third character in the misspelled variable name.

Michael Madsen
+2  A: 

Whenever I find myself in this kind of situation, I try searching for the variable and with incrsearch on you get to see whether all the relevant portions are highlighted.

In this case, if you had searched for jstlint_status sure enough the assignment operation wont be highlighted.

As kemp points out in the comments, you could hit * on the variable of instance and see if the assignment operation is highlighted or not. It amazes how useful * is. No wonder it is called the Super Star

jeffjose
that's a good technique. I love it. thanks. I was going word by word to ensure variables are spelled correctly.
Nadal
For even faster searching, just press `*` on any keyword of interest.
kemp
+1 for mentioning the SuperStar
jeffjose