I've got this problem. It's probably easy to fix, but I really don't know how.
If I begin combat near a mob in melee range, I'll start attacking it with my melee weapon, but I'm a caster. I tried fiddling with a bunch of different settings, and no matter what I do...if I'm in melee range, I won't cast spells, I'll just hit them with my sword.
For example, if I stand right next to a mob, then press End, it'll start hitting that mob with my sword. If I stand just like one foot away from it and press End, I'll start casting spells and I'll kill it. If the mob comes close to me, I'll start hitting it with my sword (usually I kill it before it reaches me, but when I fight groups of mobs that happens often).
How do I fix this?