Replace echo chapter with ex-mode

This commit is contained in:
Igor Irianto 2021-02-13 11:56:18 -06:00 committed by GitHub
parent 879a6d6e03
commit 36f69c4422
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,9 +25,11 @@ Vim has 10 different data types:
I will cover the first six data types here. In Ch. 27, you will learn about Funcref. For more about Vim data types, check out `:h variables`.
## Echo
## Following Along With Ex Mode
Since Vim does not technically have a REPL, you can use `echo` or `echom` commands. The former prints the evaluated expression you give. The latter does the same, but in addition, it stores the result in the message history.
Vim technically does not have a built-in REPL, but it has a mode, Ex mode, that can be used like one. You can go to the Ex mode with `Q` or `gQ`. The Ex mode is like an extended command-line mode (it's like typing command-line mode commands non-stop). To quit the Ex mode, type `:visual`.
You can use either `:echo` or `:echom` on this chapter and the subsequent Vimscript chapters to code along. They are like `console.log` in JS or `print` in Python. The `:echo` command prints the evaluated expression you give. The `:echom` command does the same, but in addition, it stores the result in the message history.
```viml
:echom "hello echo message"
@ -45,8 +47,6 @@ To clear your message history, run:
:messages clear
```
For the remaining of the chapter, I will use `:echo` (because it is one letter shorter), but you are more than welcome to use `:echom` or other methods.
## Number
Vim has 4 different number types: decimal, hexadecimal, binary, and octal. By the way, when I say number data type, often this means an integer data type. In this guide, I will use the terms number and integer interchangeably.