[Linux] Mengaktifkan Syntax Highlighting Pada Editor Teks Nano
Masih menggunakan file .nanorc, kita coba mengaktifkan Syntax Highlighting pada editor teks Nano, karena Nano sebenernya dah support untuk pewarnaan tapi secara default tidak ada konfigurasinya. Jadi konfigurasinya harus kita tambahin sendiri.
Untuk menambahkan pewarnaan pada Nano sebenernya harus udah ngerti dulu penggunaan regular expression, tapi di dunia maya sudah tersedia beberapa versi syntax untuk bahasa pemrograman populer.
Ini dicomot dari beberapa situs web.
PHP
syntax "php" "\.php[2345s~]?$" color brightblue "(.*)\(" #Changed this one to a character class instead of "=*|=*|<|>|!": color blue "\$[a-zA-Z_0-9$]*|[=!<>]" color green "(var|class|function|echo|case|break|default|exit|switch|if|else|elseif|@|while)\s" color green "[.,{}();]" color red "('.*')|(\".*\")" #Forces regex to stop matching at EOL. #Sometimes the dot . matches newline as well so this is more portable: color brightyellow "(#.*|//.*)$" color brightyellow start="/\*" end="\*/" #not all php open tags are "long" #I wanted to write (<\?(?!xml)(php)?|\?>) but the parser didn't support it. color brightblue "(<\?(php)?|\?>)" #unfortunately, this also makes the php tags themselves white. #But I'll live anyway color white start="\?>" end="<\?(php)?" |
PYTHON
syntax "python" "\.py$" color brightblue "def [a-zA-Z_0-9]+" color brightcyan "\<(and|assert|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|map|not|or|pass|print|raise|return|try|while)\>" color brightgreen "([\"']).*?[^\\]\1" color brightgreen start="\"\"\"" end="\"\"\"" color brightred "#.*$" |
HTML
syntax "HTML" "\.html$" color blue start="<" end=">" color red "&[^; ]*;" |
C/C++
syntax "c-file" "\.(c|C|cc|cpp|h|H|hh|hpp)$" color red "\<[A-Z_]{2,}\>" color green "\<(float|double|bool|char|int|short|long|sizeof|enum|void|static|const|struct|union|typedef|extern|signed|unsigned|inline)\>" color green "\<(class|printf|namespace|template|public|protected|private|typename|this|friend|virtual|using|mutable|volatile|register|explicit)\>" color brightyellow "\<(for|if|while|do|else|case|default|switch|goto|continue|break|return)\>" color brightyellow "\<(try|throw|catch|operator|new|delete)\>" color brightcyan "^ *# *(define|undef|include|ifn?def|endif|elif|else|if)" color brightmagenta "'([^\]|(\\['abfnrtv\\]))'" "'\\(([0-7][0-7]?)|([0-3][0-7][0-7]))'" "'\\x[0-9A-Fa-f][0-9A-Fa-f]?'" |
JAVA
syntax "Java source" "\.java$" color green "\<(boolean|byte|char|double|float|int|long|new|short|this|transient|void)\>" color red "\<(break|case|catch|continue|default|do|else|finally|for|if|return|switch|throw|try|while)\>" color cyan "\<(abstract|class|extends|final|implements|import|instanceof|interface|native|package|private|protected|public|static|strictfp|super|synchronized|throws|volatile)\>" color red ""[^\"]*"" color yellow "\<(true|false|null)\>" color blue "//.*" color blue start="/\*" end="\*/" color brightblue start="/\*\*" end="\*/" color brightgreen,green " +$" |
Shell Script
syntax "shellscript" "\.sh$" color brightgreen "^[a-zA-Z_0-9]+\(\)" color green "\<(case|do|done|elif|else|esac|exit|fi|for|function|if|in|local|read|return|select|shift|then|time|until|while)\>" color green "(\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|)" color green "-(e|d|f|r|g|u|w|x|L)\>" color green "-(eq|ne|gt|lt|ge|le|s|n|z)\>" color brightblue "\<make\>" "\<(cat|cd|chmod|chown|cp|echo|env|export|grep|install|let|ln|mkdir|mv|rm|sed|set|tar|touch|umask|unset)\>" color brightred "\$\{?[a-zA-Z_0-9]+\}?" color yellow "#.*$" color brightyellow ""(\\.|[^\"])*"" "'(\\.|[^'])*'" |
Pascal
syntax "Delphi Source" "\.pas$" color brightcyan "\<(boolean|byte|char|double|float|integer|long|new|short|this|transient|void)\>" color brightred "\<(break|case|catch|continue|default|do|else|finally|for|if|then|return|switch|throw|try|while|function)\>" color cyan "\<(abstract|unit|class|extends|final|implements|import|instanceof|interface|native|package|private|protected|public|static|strictfp|super|$color brightyellow "\<(until|repeat|var|uses|type|begin|end|const)\>" color magenta "\<(true|false|null|procedure)\>" color brightblue "//.*" color brightblue start="\{" end="\}" |
Sumber:
http://www.linuxhowtos.org/System/
http://ubuntuforums.org/forumdisplay.php?f=100
http://forums.gentoo.org/viewforum-f-12.html
IP Address-mu:
38.107.191.81


