文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>vim/nano/emacs实现php语法高亮

vim/nano/emacs实现php语法高亮

时间:2006-11-01  来源:keer2345


  • 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


相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载