# Execute

It's a little bit like a $(eval)

`:execute "echom 'Hello, world!'"`

`:execute "rightbelow vsplit " . bufname("#")`

### Is Execute Dangerous?

In most programming languages the use of such an "eval" construct to evaluate strings as program code is frowned upon (to put it lightly). Vimscript's execute command doesn't have the same stigma for two reasons.

First, most Vimscript code only ever takes input from a single person: the user. If the user wants to input a tricky string that will cause an execute command to do something bad, well, it's their computer! Contrast this with other languages, where programs constantly take input from untrusted users. Vim is a unique environment where the normal security concerns simply aren't common.

The second reason is that because Vimscript has sometimes arcane and tricky syntax, execute is often the easiest, most straightforward way to get something done. In most other languages using an "eval" construct won't usually save you much typing, but in Vimscript it can collapse many lines into a single one.

## Exercises

Skim :help execute to get an idea of some of the things you can and can't use execute for. Don't dive too deeply yet -- we're going to revisit it very soon.

Read :help leftabove, :help rightbelow, :help :split, and :help :vsplit (notice the extra colon in the last two topics).

Add a mapping to your \~/.vimrc file that opens the previous buffer in a split of your choosing (vertical/horizontal, above/below/left/right).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://fashaun.gitbook.io/dev-vim/execute.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
