Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tutorials:emacs-tutorial [2012/02/18 17:14] memnontutorials:emacs-tutorial [2012/05/02 17:08] (current) – Minor fix memnon
Line 66: Line 66:
 Emacs has a nice search mode called //incremental search//. To use it, type "C-s". The text "I-search:" will appear in the echo area. Now start typing a search string. As you type, Emacs will search for your string in real-time (starting at point), highlighting any matches it finds. You can backspace and re-type text, and the search will continue to change with the text you type. When you find a match, you can hit "C-s" to search again and jump to the next match, or you can just hit "Enter" to exit the search mode and leave the cursor at the last match. "C-g" will abort the search and put your cursor back where you started. Searches will re-start at the top of a buffer if they hit the bottom. You can search backwards in a similar fashion with "C-r". Emacs has a nice search mode called //incremental search//. To use it, type "C-s". The text "I-search:" will appear in the echo area. Now start typing a search string. As you type, Emacs will search for your string in real-time (starting at point), highlighting any matches it finds. You can backspace and re-type text, and the search will continue to change with the text you type. When you find a match, you can hit "C-s" to search again and jump to the next match, or you can just hit "Enter" to exit the search mode and leave the cursor at the last match. "C-g" will abort the search and put your cursor back where you started. Searches will re-start at the top of a buffer if they hit the bottom. You can search backwards in a similar fashion with "C-r".
  
-To replace text that matches a search pattern, type "M-%". You'll see "Query replace:" in the echo area. Type a search string, and hit "Enter". The echo area will now display "Query replace &lt;search string&gt; with:". Type the replacement string, and hit "Enter" again. Emacs will search through your buffer, looking for the search string. When it finds it, it will display "Query replacing &lt;search string&gt; with &lt;replacement string&gt;: (? for help)". Type "y" to replace this match and move onto the next, or "n" to skip this match. Type "!" to replace this occurrence of the search string and all other occurrences in your buffer without prompting. As usual, you can type "C-g" to abort a search/replace operation.+To replace text that matches a search pattern, type "M-%". You'll see "Query replace:" in the echo area. Type a search string, and hit "Enter". The echo area will now display "Query replace <search stringwith:". Type the replacement string, and hit "Enter" again. Emacs will search through your buffer, looking for the search string. When it finds it, it will display "Query replacing <search stringwith <replacement string>: (? for help)". Type "y" to replace this match and move onto the next, or "n" to skip this match. Type "!" to replace this occurrence of the search string and all other occurrences in your buffer without prompting. As usual, you can type "C-g" to abort a search/replace operation.
  
 All searches in Emacs are case-insensitive by default, unless you type at least one capital letter in your search string - in that case, the search becomes case-sensitive. All searches in Emacs are case-insensitive by default, unless you type at least one capital letter in your search string - in that case, the search becomes case-sensitive.
Line 202: Line 202:
  
 The above example gives you a good idea of what can be done in a ".emacs" file, for more in-depth configuration Emacs has a customization mode that can be accessed with the extended command "M-x customize". Running it will put you in a curses-style application where you can choose from customization menus and have your changes written to your ".emacs" file automatically. The above example gives you a good idea of what can be done in a ".emacs" file, for more in-depth configuration Emacs has a customization mode that can be accessed with the extended command "M-x customize". Running it will put you in a curses-style application where you can choose from customization menus and have your changes written to your ".emacs" file automatically.
 +
 +===== Browsing the Web in Emacs with w3m =====
 +
 +[[http://sourceforge.net/projects/w3m/files/|Emacs w3m mode]] will use the excellent [[http://w3m.sourceforge.net|w3m]] text-mode browser and allow you to surf the web in an Emacs buffer.
 +To get started, add the following to your .emacs file:
 +
 +  (require 'w3m-load)
 +
 +Then restart emacs, or place the cursor at the end of each line in turn and press C-x e. Then you can open a new w3m buffer with M-x w3m. The basic key bindings are as follows (note that these are taken from the w3m-mode help page, which can be accessed at any time in a new window with C-h m):
 +
 +| M-x w3m | Start browsing web with emacs-w3m.                            |
 +| q       | Close all emacs-w3m windows, without deleting buffers.        |
 +| Q       | Exit browsing web. All emacs-w3m buffers will be deleted.     |
 +| RET     | Display the page pointed to by the link under point.          |
 +| C-c C-c | Submit the form at point.                                     |
 +| R       | Reload the current page.                                      |
 +| r       | Redisplay the current page.                                   |
 +| TAB     | Move the point to the next anchor.                            |
 +| M-TAB   | Move the point to the previous anchor.                        |
 +| B       | Move back to the previous page in the history.                |
 +| N       | Move forward to the next page in the history.                 |
 +| U       | Visit the web page.                                           |
 +| H       | Go to the Home page.                                          |
 +| M-d     | Download the URL.                                             |
 +| d       | Download the URL under point.                                 |
 +| \       | Display the html source of the current page.                  |
 +| SPC     | Scroll up the current window, or go to the next page.         |
 +| b       | Scroll down the current window, or go to the previous page.   |
 +| >       | Scroll to the left.                                           |
 +| <       | Scroll to the right.                                          |
 +| .       | Shift to the left.                                            |
 +| ,       | Shift to the right.                                           |
 +| M-l     | Recenter horizontally.                                        |
 +| j       | Next line.                                                    |
 +| k       | Previous line.                                                |
 +| l       | Forward char.                                                 |
 +| h       | Backward char.                                                |
 +| s       | Display the history of pages you have visited in the session. |
 +| S       | Prompt for a search query and submit it to google.            |
 +| v       | Display the bookmarks list.                                   |
 +| a       | Add a url of the current page to a new bookmark.              |
 +| M-a     | Add the url under point to a new bookmark.                    |
 +
 +There are many more features in w3m-mode, the mode help text details them all with keybindings. To end your session and close all w3m buffers, just press Q and answer y when prompted.
  
 ===== Where to Go From Here ===== ===== Where to Go From Here =====
  
-Below are some links to resources and useful Emacs Lisp packages Many Linux and BSD-based operating systems have packages for most of these, so check there before you attempt to install by hand:+Below are some links to resources and useful Emacs Lisp packagesMany Linux and BSD-based operating systems have packages for most of these, so check there before you attempt to install by hand:
  
   * [[http://www.gnu.org/software/emacs/tour/|Emacs Tour]]: Guided tour of GNU Emacs with lots of screenshots.   * [[http://www.gnu.org/software/emacs/tour/|Emacs Tour]]: Guided tour of GNU Emacs with lots of screenshots.
-  * [[http://emacs-w3m.namazu.org/|W3m]]: Runs w3m plus some other nice features for web-browsing within emacs (the latest sources can be downloaded from [[http://sourceforge.net/projects/w3m/files/|Sourceforge]]). 
   * [[http://mwolson.org/projects/EmacsMuse.html|Muse]]: A publishing and authoring environment that converts simple text markup into HTML, PDF, Texinfo, Docbook, LaTeX, Blosxom blog entries and more. This tutorial was written using muse-mode.   * [[http://mwolson.org/projects/EmacsMuse.html|Muse]]: A publishing and authoring environment that converts simple text markup into HTML, PDF, Texinfo, Docbook, LaTeX, Blosxom blog entries and more. This tutorial was written using muse-mode.
-  * [[http://www.emacswiki.org/cgi-bin/wiki|Emacs Wiki]]: Loads of tips and howtos. $Id: emacs-tutorial.html,v 1.10 2010/08/05 19:30:23 slugmax Exp $+  * [[http://www.emacswiki.org/cgi-bin/wiki|Emacs Wiki]]: Loads of tips and howtos.  
 + 
 +$Id: emacs-tutorial.html,v 1.14 2012/05/02 13:42:40 slugmax Exp $