> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Basic File Editing configure the standard editor

> This article explains how to configure your shell's default text editor for improved efficiency when editing files.

Changing the shell’s default text editor lets you work faster when editing files like your crontab. By default, most UNIX-like systems use `vi` or `vim`. Bash determines which editor to launch by checking two environment variables:

| Variable | Purpose                       | Examples       |
| -------- | ----------------------------- | -------------- |
| VISUAL   | Full-screen, visual editors   | `vim`, `emacs` |
| EDITOR   | Simple, line-oriented editors | `nano`, `ed`   |

<Callout icon="lightbulb" color="#1CB2FE">
  If both `VISUAL` and `EDITOR` are set, many programs will prefer `VISUAL`. To ensure consistency, consider exporting both variables.
</Callout>

## 1. Setting the Editor for the Current Session

To switch to `nano` for just the active shell session, export the `EDITOR` variable:

```bash theme={null}
export EDITOR=nano
```

After running this, any program in this session that relies on your default editor will open `nano` instead of `vi`.

<Callout icon="triangle-alert" color="#FF6B6B">
  This change only applies to the current session. Close the terminal or start a new shell, and you’ll revert to the previous default.
</Callout>

## 2. Making the Change Permanent

To have `nano` (or another editor) as your default every time you open a new shell, add the export line to your Bash startup file. Most users place it in `~/.bash_profile`:

```bash theme={null}
vi ~/.bash_profile
```

Inside the file, append:

```bash theme={null}
export EDITOR=nano
```

Save and exit. From now on, all new Bash sessions for that user will launch `nano` as the standard editor.

## Links and References

* [GNU Bash Manual: Invoking Bash](https://www.gnu.org/software/bash/manual/html_node/Invoking-Bash.html)
* [Environment Variables in Linux](https://www.gnu.org/software/sh-utils/manual/html_node/Environmental-Variables.html)
* [Nano Editor Documentation](https://www.nano-editor.org/docs.php)

<Callout icon="lightbulb" color="#1CB2FE">
  Check your understanding with the quiz.
</Callout>

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/linux-professional-institute-lpic-1-exam-101/module/2490f961-886c-4531-be8c-915cccff60a9/lesson/c52d877a-3522-4ac9-b7ee-0a6df6f95ae3" />
</CardGroup>
