Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VIM Spellcheck, Within Quoted Strings - PHP

I was wondering if it would be possible to run the vim spell checker while coding with PHP. I can run it if I disable syntax highlighting, and it highlights almost all methods/function names because they are not English words.

So, my question is this, can I run the spell check on just the strings within PHP files?

For example, just within the ' quotes (and " quotes), ignoring everything else:

$paragraph = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. In est libero, dictum ut suscipit eget, lacinia in justo. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Praesent sit amet sem libero, in pretium enim. Pellentesque tortor ante, imperdiet quis mattis in, tincidunt et ligula. Cras porta velit a ligula venenatis placerat.';

$paragraph2 = "Vestibulum quis eleifend lectus. Vestibulum odio odio, mollis at eleifend a, adipiscing sed quam. Nam quis nisi quis mauris faucibus hendrerit eu a leo. Sed feugiat purus sit amet purus congue quis semper diam malesuada. Vivamus et enim non arcu pretium sollicitudin. Nullam blandit, lorem eu aliquet tincidunt, enim mauris placerat lectus, id faucibus nulla lectus non elit. Sed eget fermentum lacus. Ut tempus pulvinar neque, vel pellentesque purus aliquet quis. Vivamus molestie pretium quam at imperdiet. Maecenas diam turpis, malesuada ut sollicitudin ac, congue eleifend urna. Quisque id ipsum eget ipsum tempus blandit at vel magna. Fusce eu felis metus.";

like image 203
Oliver O'Neill Avatar asked Sep 07 '10 16:09

Oliver O'Neill


1 Answers

see the vim help: :help spell-syntax

You can define particular syntax groups as having spell checking.

There's probably a better way to do it (using a ~/.vim/after/syntax/php.vim file?), but a simple hack is to make a personal version of the php syntax file in ~/.vim/syntax (you can do this by doing :e $VIMRUNTIME/syntax/php.vim and the :saveas ~/.vim/syntax/php.vim), and change all instances of the text contains=@phpAddStrings to contains=@Spell,@phpAddStrings. Next time you open a php file, turn on spell checking as normal with :set spell.

like image 149
Michael Dunn Avatar answered Oct 13 '22 10:10

Michael Dunn