Chinaunix首页 | 论坛 | 博客
  • 博客访问: 676451
  • 博文数量: 156
  • 博客积分: 6010
  • 博客等级: 准将
  • 技术积分: 1201
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-05 20:08
文章分类

全部博文(156)

文章存档

2010年(13)

2008年(39)

2007年(104)

我的朋友

分类: LINUX

2008-06-02 19:01:47

让firefox使用emacs的键盘绑定

Emacs Keybindings - Firefox

From MozillaZine Knowledge Base

(Redirected from )

Contents

[]
[]

GNU/Linux

Firefox uses the GTK setting to determine whether Emacs-like/Readline-like keybindings are active in text fields. There are two different methods depending upon whether or not you run Gnome. If in doubt, it doesn't hurt to do both.

[]

Standard method: .gtkrc-2.0

这样就可以了

To enable Emacs keybindings, add the line

gtk-key-theme-name = "Emacs"

to ~/.gtkrc-2.0 (create the file if it doesn't exist) and restart Firefox. For some versions (1.5.0.1) of firefox this filename is ~/.gtkrc

[]

Gnome method: gconftool-2

If the above method doesn't work, it is probably because you are running Gnome >=2.8 which has a Microsoft Windows® style "registry" called GConf. There is a graphical registry editor, gconf-editor, but you don't have to use it. Just cut and paste this into the command line,

gconftool-2 --set /desktop/gnome/interface/gtk_key_theme Emacs --type string

You need not restart. All current and future firefox processes will now use Emacs key bindings. If you decide that you don't like it, you can use --unset.

[]

The Keybindings

The shortcuts are often called Emacs keybindings, but they're actually more similar to keybindings in Readline. When these keybindings are enabled, they override the standard keybindings in Gnome and Firefox (when a text entry field has focus).

Ctrl+A Go to beginning of line
Ctrl+E Go to end of line
Ctrl+F Go right one character
Ctrl+B Go left one character
Ctrl+P Go to previous line ("up") (only works in multiline text areas)
Ctrl+N Go to next line ("down") (only works in multiline text areas)
Ctrl+K Delete to end of line (if cursor is at the end of the line, deletes the following newline)
Ctrl+U Delete entire line (different from readline, in which Ctrl+U deletes to the beginning of the line)
Ctrl+W Delete word, left
Ctrl+H Delete character, left (backspace)
Ctrl+D Delete character, right
[]

Unsupported keys

Additional Readline keys not supported by Firefox.

Ctrl+T transpose characters
Ctrl+Y yank (like paste)
Ctrl+S search
Ctrl+R reverse search
Ctrl+J return
Ctrl+M carriage return
Ctrl+L redraw
[]

Any OS: Conkeror

Conkeror is an extension which makes Firefox look and act like Emacs. It is a much more thorough change to the UI than simple key bindings and is not for the faint of heart. Conkeror can be selectively disabled so that "normal" Firefox windows can be opened simultaneously with Conkeror windows.

[]

Windows

For Windows you can download , an OpenSource keybinder that works with most Windows apps. You can also follow the instructions below.

[]

Any OS, without GTK

For both Windows and OS X, you can manually edit the platformHTMLBindings.xml file and add the handlers listed below to each section for which you desire the new bindings. (On OS X, you will need to open show the contents of the application package by choosing "Show package contents" from the contextual menu of the application in the Finder. Then you have to browse to Contents/MacOS/ within the package.) Locate the file as appropriate for your browser version, then add the entries below and restart the browser.

[]

Versions preceding 1.0.5

For versions before 1.0.5 this file is located at $MOZILLA_HOME/res/builtin/platformHTMLBindings.xml.

[]

Versions following 1.0.5

As of version 1.0.5 platformHTMLBindings.xml has moved inside the archive $MOZILLA_HOME/chrome/toolkit.jar (content/global/platformHTMLBindings.xml within the JAR file). You'll need to extract the existing file from the archive, modify it, then update the archive with the modified file.

The simplest way to modify the file is to move the jar file to a working directory, unpack it, modify the desired file, then recompress the jar and replace the older one. You may want to make a backup of this file in case anything goes wrong. Follow these steps, where $MOZILLA_HOME is replaced with your Mozilla/Firefox install directory and $WORKING_DIRECTORY is a directory you select:

Move the JAR file to a working directory:

cd $MOZILLA_HOME/chrome/
cp toolkit.jar $WORKING_DIRECTORY
cd $WORKING_DIRECTORY

Unpack the JAR file with the Java Archive Utility (you can alternatively use unzip and zip -r instead of jar -xf and jar -cf):

jar -xf toolkit.jar

Modify the file which will now be located at $WORKING_DIRECTORY/content/global/platformHTMLBindings.xml. Add the entries listed below, then repack the JAR file:

cd $WORKING_DIRECTORY
jar -cf toolkit.jar content/

Copy the new JAR file back. (You may want to make a backup!)

cp toolkit.jar $MOZILLA_HOME/chrome/


Restart the browser for the change to take effect.


Note: User-controlled keybindings will be available once Bug 201011 (custom key bindings no longer possible) is fixed.

[]

Entries to add to platformHTMLBindings.xml

Add to the section of :











Add to the section of and :














管理员在2009年8月13日编辑了该文章文章。
-->
阅读(2649) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~