Return to Video

Emacs Rocks! Episode 09: expand-region

  • 0:01 - 0:04
    Welcome back to emacs rocks
  • 0:04 - 0:10
    today I'll show you my definitely most favourite feature
  • 0:10 - 0:13
    of IntelliJ IDEA
  • 0:13 - 0:17
    selecting stuff by semantic units
  • 0:17 - 0:20
    it's an absolutely addictive feature
  • 0:20 - 0:22
    and JetBrains, in their infinite wisdom,
  • 0:22 - 0:26
    mapped it to Command-W on the mac
  • 0:26 - 0:30
    also known as Close Window ...
  • 0:30 - 0:32
    I still carry with me the frustration,
  • 0:32 - 0:36
    and bitterness over once again closing Firefox
  • 0:36 - 0:39
    with *all my tabs*
  • 0:39 - 0:42
    instead of selecting a word.
  • 0:42 - 0:45
    So, let's jump in and take a look at expand-region
  • 0:45 - 0:50
    and let's definitely not bind it to Command-W.
  • 0:51 - 0:55
    I've got expand-region on Control-@
  • 0:55 - 0:56
    look at point
  • 0:56 - 0:59
    see how it first selects the entire word
  • 0:59 - 1:01
    it expands to the entire sentence ...
  • 1:01 - 1:05
    the quotes ... the inside of the sexp ...
  • 1:05 - 1:09
    the entire sexp ... and so on
  • 1:09 - 1:15
    It's really a quick way of precisely marking whatever is at point
  • 1:15 - 1:17
    let's try some HTML
  • 1:17 - 1:20
    expand region works fairly well with most languages,
  • 1:20 - 1:24
    due to the general nature of its basic expansions
  • 1:24 - 1:29
    but there are also custom expansions to improve certain modes
  • 1:29 - 1:32
    like expand-html-attribute
  • 1:32 - 1:36
    and marking an entire tag
  • 1:41 - 1:43
    here's some JavaScript
  • 1:43 - 1:45
    expand to word ...
  • 1:45 - 1:47
    method call ... return statement ...
  • 1:47 - 1:52
    block ... function ... object property
  • 1:57 - 2:01
    I especially like using it with pending-delete-mode
  • 2:01 - 2:03
    if you start typing with an active region,
  • 2:03 - 2:08
    the contents are replaced with whatever you type.
  • 2:11 - 2:16
    you can get expand-region on github
  • 2:17 - 2:21
    and thanks to Josh Johnston and Le Wang for contributing
  • 2:21 - 2:27
    I have to say, I'm really loving the extensibility of emacs
  • 2:27 - 2:30
    whenever people brag about some cool new features
  • 2:30 - 2:32
    in their favourite editor,
  • 2:32 - 2:35
    I always pay close attention
  • 2:35 - 2:36
    who knows -
  • 2:36 - 2:38
    I might decide to spend a couple of hours
  • 2:38 -
    adding it to emacs.
Title:
Emacs Rocks! Episode 09: expand-region
Description:

http://emacsrocks.com - Rocking emacs tricks and tips screencast.

Follow me on twitter: @emacsrocks

more » « less
Video Language:
English
Duration:
02:40
magnarsveen added a translation

English subtitles

Revisions