As romainl suggested, you can achieve so with the conceal feature of vim.
Here is a script example that can be used:
let rules = [
\ ['01' , '☺'],
\ ['02' , '☻'],
\ ['03' , '♥'],
\ ['04' , '♦'],
\ ['05' , '♣'],
\ ['06' , '♣'],
\ ['07' , '•'],
\ ['08' , '◘'],
\ ['^A' , '¢'],
\ ]
for [value, display] in rules
execute "syntax match vartest /".value."/ conceal cchar=".display
endfor
" Ensure the character is concealed
set conceallevel=2
set concealcursor=nvc
As you can see, I took some of the seriously mapping and your ^A example.
Careful if you want to copy/paste this code, the ^A needs to be typed <C-v> <C-A>.
What this code does is, it define for each value/display pair a syntax matching.
e.g.
syntax match vartest /08/ conceal cchar=◘
Will match every 08 sequence and the file and conceal them with the ◘ character.
You will see ◘, but the actual text in the file is 08.
You can then take a list of rules and (with a fancy macro, i.e. for seriously: 0i\ ['^[f s', '^[lxf)s'],^[ld$) transforme each line into a usable vim array.
Also, if you want to type literal unicode with vim, you can use this workflow:
<C-V> u XXXX
Where XXXX is the unicode value, so typing <C-V>u0001 will insert ^A as desired.
If you want to verify the content of the file, I recommend using a hex dump of the file, that you can have with xxd.
e.g.
$ vim
<C-V><C-A><C-V><C-B>
:x a.txt
$ xxd a.txt
0000000: 0102 0a ...
You can see here your ^A as 01 and your ^B as 02. (0a represents the new line at the end of the file)
:help conceal. – romainl Jun 07 '16 at 07:19encodingandcharconvertI saw that it internally tries to use theiconvfunction first to convert character sets.iconvcan handle conversion between different character sets. An answer on to how to add a character set toiconvcan be found here (seems you have to mail the maintainer). Maybe this helps you. :) – user2609980 Jun 11 '16 at 17:46