" Vim syntax file " Language: Portable Game Notation (*.pgn) " Maintainer: Ryan Sarson " Last Change: 2022-04-30 " Original Author: Charles Ford " http://www.vim.org/scripts/script.php?script_id=677 " References: PGN-SPEC " https://www.chessclub.com/help/PGN-spec " Portable Game Notation " https://en.wikipedia.org/wiki/Portable_Game_Notation " FIDE Laws of Chess Appendix C. Algebraic notation " https://www.fide.com/component/handbook " Algebraic Notation " https://en.wikipedia.org/wiki/Algebraic_notation_(chess) " Note: This script interprets PGN files which use standard algebraic " notation as required by FIDE (Laws of Chess, Appendix C). " Additionally, it recognizes some of the more commonly used " notations, as mentioned in the Wikipedia article on algebraic " notation. This allows for syntax highlighting of PGN import format " files (see PGN-SPEC). Examples of these included those generated by " Scid (Shane Hudson) and Chessmater (Ubisoft), as well as the many " downloadable chess databases available on the Internet. " for testing syntax match pgnError /\S/ highlight link pgnError ErrorMsg " ***************** " *** Tag pairs *** " ***************** syntax region pgnTagName start=/\[/ end=/\]/ contains=pgnTagValue syntax region pgnTagValue start=/"/ skip=/\\"/ end=/"/ contained " **************** " *** Movetext *** " **************** " move number " - pgn requires 1.e4 or 1...e5 " - pattern: whitespace number whitespace? period? whitespace? ellipsis? syntax match pgnMoveNumber /\%(^\|\s\)\zs\d\+\%(\_s*\.\{3,4}\|\%(\%(\_s*\.\)\?\%(\_s*\.\{3}\)\?\)\)\ze\%(--\|[^-/]\|\_s\)/ " piece " - fide and pgn do not identify pawn by a letter syntax match pgnPiece /[KQRBNP♔♕♖♗♘♙♚♛♜♝♞♟]/ " file and/or rank of departure " - used for disambiguation or in long algebraic notation syntax match pgnDeparture /\%(ch\)\@!\%(\%([1-8]\)\@1/ " variations " - can be nested; excludes parentheses promotion, draw offer syntax region pgnVariation start=/\%(([=QRBN])\)\@!(/ end=/)\%(([=QRBN])\)\@3