Skip to content

Verbose mode

DJMcMayhem edited this page Jan 26, 2017 · 1 revision

Vim uses lots of Control characters, which is fine for an interactive editor but very inconvenient for a language, since control characters are usually unprintable. V suffers from this problem, and since it adds non-ASCII characters, the problem is even worse.

One way to get around this problem is by using vim to write V code. That way, typing unprintable characters is easy, for example using <C-v><esc> to enter a literal escape character, or using various mnemonics to type the extended V commands. For example, typing <M-D> in vim will insert the uppercase duplicate operator, or Ä. Unfortunately, the entered characters are different if you use vim is OS X. You can use this vimscript function to simulate the effects of the alt key under Windows or Linux:

function! Alt()
  let c = nr2char(getchar() + 128)
  exec 'normal gi'.c
endfunction

inoremap <C-i> <C-o>:call Alt()<cr>

Then to insert an <M-D> you may simply type <C-i>D. Of course you may change this mapping to whatever is most convenient for you.

This is my preferred solution, but I'm biased because vim is my preferred text editor. It's not reasonable to expect everyone to use vim. The other way to get around this is too use verbose mode. To use verbose mode, simply call V with the -v flag, or add -v to the list of arguments on TIO. In verbose mode, all mnemonics and unprintable characters work normally, but characters may be surrounded in brackets to signal that it is a non-ASCII character. For example, you may use these for control characters:

<C-a>:  control-a (ASCII 0x01)
<C-b>:  control-b (ASCII 0x02)
<C-c>:  control-c (ASCII 0x03)
...
<C-z>:  control-c (ASCII 0x1A)
<esc>:  escape (ASCII 0x1B)
<lb>:   left bracket "<"
<rb>:   left bracket ">"
<bs>:   backspace (ASCII 0x08)
<del>:  Delete (ASCII 0X7f)

You may also use <M-a> to symbolize the mnemonics for characters. Here's a nice example that demonstrates how to use verbose mode: Try it online!

The only downside to verbose mode is that it makes it harder to tell what the correct byte count for a solution is. That example corresponds to a 16-byte V program.

Clone this wiki locally