免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4003 | 回复: 0
打印 上一主题 下一主题

vim/nano/emacs实现php语法高亮 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-11-01 09:24 |只看该作者 |倒序浏览

  • vim

在 /etc/vim/vimrc 最后添加
:syntax enable
:source $VIMRUNTIME/syntax/php.vim

  • nano

在 /etc/nanorc 最后添加

syntax "php" ".*/*.php$"
color brightwhite "\{|\}|\."
color red "('[^']*')"
color red "\"[^\"]*\""
color brightblue "(\$([[:alpha:]_]|->)*)"
color brightgreen "((\$(([[:alpha:]_0-9])+\->)+)[[:alpha:]_0-9]+\()"
color yellow " (if|else if|else|return|case|break)"
color yellow "\|\||\?|!|\||&&|=|;|\(|\)"
color red "false|true"
color brightwhite "[[:space:]]+debug|[[:space:]]+echo|\$this\->debug"
color cyan "//.*"
color cyan start="/\*" end="\*/




  • emacs


http://sourceforge.net/projects/php-mode/

下载php-mode.el
http://www.emacswiki.org/cgi-bin/wiki/HtmlModeDeluxe

有在同文件里混合代码的处理说明需要mmm支持
在php-mode.el
添加代码如下
;;添加debug函数和菜单,phpdebug.exe是zend里那个改名来的
(define-key php-mode-map
[menu-bar php php-debug]
'(
"Debug the PHP Program" . php-debug))
(
defun php-debug ()
(interactive)
(shell-command
(concat
"d:/emacs/bin/phpdebug.exe \""
(read-file-name
"Input file name: ")
"\""))
)

;;添加运行函数和菜单
(define-key php-mode-map
[menu-bar php php-run]
'(
"Run the PHP Program" . php-run))
(
defun php-run ()
(interactive)
(shell-command
(concat
"d:/emacs/php5/php.exe -f \""
(read-file-name
"Input file name: ")
"\""))
)

;;添加快捷键盘
(define-key php-mode-map
"\C-c\C-d"
'php-debug)

;; 添加快捷键盘
(define-key php-mode-map
"\C-c\C-r"
'php-run)
添加代码到.emacs如下
;; PHP 语法支持,需要MMM模块的添加才支持混合代码  
(add-to-list 'load-path (expand-file-name "~/site-lisp/mmm-mode"))
(require 'php-mode)
(add-hook 'php-mode-user-hook 'turn-on-font-lock)
(require 'mmm-mode)
(setq mmm-global-mode 'maybe)
(mmm-add-group
'php-in-html
'(
(html-php-tagged
:submode php-mode
:front "\\?"
:back "\\?>"
:include-back t)))
(add-hook 'html-mode-hook '(lambda ()
(setq mmm-classes '(php-in-html))
(set-face-background
'mmm-default-submode-face "Blank")
(mmm-mode-on)))
(add-to-list 'auto-mode-alist '("\\.php[34]?\'" . html-mode))
(add-to-list 'mmm-mode-ext-classes-alist '(html-mode nil fancy-html))
;;代码折叠,这个你肯定需要吧
(load-library "hideshow")
(add-hook 'php-mode-hook 'hs-minor-mode)
以下为调试程序和运行程序时输出地样子

PHP Debug

PHP Run


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/10869/showart_193381.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP