# How to evaluate a single expression?

**URL:** <https://racket.discourse.group/t/how-to-evaluate-a-single-expression/1511>\
**Category:** General\
**Tags:** drracket\
**Created:** [November 26, 2022, 12:25pm UTC](https://racket.discourse.group/t/how-to-evaluate-a-single-expression/1511 "2022-11-26T12:25:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ceving](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@ceving](https://racket.discourse.group/u/ceving)\
**Post date:** [November 26, 2022, 12:25pm UTC](https://racket.discourse.group/t/how-to-evaluate-a-single-expression/1511/1 "2022-11-26T12:25:13Z")

</div>

I am looking for the equivalent of C-x C-e in Emacs' Scheme mode. In Emacs the function eval-last-sexp gets evaluated. If you put the cursor on a closing parenthesis, the code up to the corresponding opening parenthesis gets evaluated. How to do this in DrRacket?

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [November 26, 2022, 1:44pm UTC](https://racket.discourse.group/t/how-to-evaluate-a-single-expression/1511/2 "2022-11-26T13:44:51Z")

</div>

FWIW in `racket-mode` in Emacs, it's still C-x X-e.

> **[Racket Mode](https://racket-mode.com/#Eval)**
>
> Racket Mode

Can't recommend racket-mode enough, if you are using Emacs.

---

<div class="post-metadata">

**Author:** ![sorawee](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@sorawee](https://racket.discourse.group/u/sorawee)\
**Post date:** [November 26, 2022, 2:03pm UTC](https://racket.discourse.group/t/how-to-evaluate-a-single-expression/1511/3 "2022-11-26T14:03:43Z")

</div>

You might want to set up a custom keybinding that does eval-last-sexp. See [https://docs.racket-lang.org/drracket/Keyboard\_Shortcuts.html#%28part._.Sending_.Program\_.Fragments\_to\_the\_.R.E.P.L%29](https://docs.racket-lang.org/drracket/Keyboard_Shortcuts.html#%28part._.Sending_.Program_.Fragments_to_the_.R.E.P.L%29) for more details.

---

<div class="post-metadata">

**Author:** ![ceving](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@ceving](https://racket.discourse.group/u/ceving)\
**Post date:** [November 26, 2022, 2:26pm UTC](https://racket.discourse.group/t/how-to-evaluate-a-single-expression/1511/4 "2022-11-26T14:26:38Z")

</div>

But it does not work as expected. See screen shot.

 ![](https://global.discourse-cdn.com/free1/uploads/racket/original/1X/827c02e44537a5d2389942a04b4188ba1a64f8ba.png)

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [November 26, 2022, 2:28pm UTC](https://racket.discourse.group/t/how-to-evaluate-a-single-expression/1511/5 "2022-11-26T14:28:30Z")

</div>

Where is the cursor here?

Before ( or after ) on line 3?

---

<div class="post-metadata">

**Author:** ![countvajhula](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/countvajhula/32/65_2.png) [@countvajhula](https://racket.discourse.group/u/countvajhula)\
**Post date:** [November 28, 2022, 7:19am UTC](https://racket.discourse.group/t/how-to-evaluate-a-single-expression/1511/6 "2022-11-28T07:19:06Z")

</div>

You may be looking for the `select-send-sexpr` [quickscript](https://docs.racket-lang.org/quickscript/index.html). There are instructions for installing it [here](https://github.com/countvajhula/qi-tutorial#drracket).
