djmcmayhem / v Goto Github PK
View Code? Open in Web Editor NEWA golfing language inspired by everybody's favorite text editor, vim.
A golfing language inspired by everybody's favorite text editor, vim.
For example, this program should output
HHello
WWorld
But does not. Or this program is a more explicit way to do the same thing (the program is <M-d><C-v>j
)
It doesn't seem to be causing issues when you override the linewise setting with V
or v
, only <C-v>
and mappings that use it.
Hi, I'd really like to be able to make nested loops in V. Would it be possible to add this functionality sometime? so like ò{big loop ò{ loop for each big loop ò} still big loop ò} maybe add a "close loop" character for ò and ñ.
When I do 0¬{char}{char}
, instead of doing nothing, it puts an �
(0x1B byte) in. Not sure why that happens...
It would be nice if programs such as:
é_.
Would output:
__
Obviously this should work for every custom command, not just <M-i>
. Look into tpope/vim-repeat for this.
System: OS X 10.11.1 (El Capitan)
**
I created an empty file named "test.V" and I ran it through the latest version of the interpreter:
$ python main.py test.V
^CTraceback (most recent call last):
File "main.py", line 71, in <module>
main()
File "main.py", line 60, in main
v_instance.clean_up()
File "/Users/vihan/Downloads/V/v.py", line 109, in clean_up
if self.get_mode() == "i":
File "/Users/vihan/Downloads/V/v.py", line 77, in get_mode
return self.nvim_instance.eval("mode(1)")
File "/usr/local/lib/python2.7/site-packages/neovim/api/nvim.py", line 209, in eval
return self.request('vim_eval', string, **kwargs)
File "/usr/local/lib/python2.7/site-packages/neovim/api/nvim.py", line 129, in request
res = self._session.request(name, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/neovim/msgpack_rpc/session.py", line 91, in request
v = self._blocking_request(method, args)
File "/usr/local/lib/python2.7/site-packages/neovim/msgpack_rpc/session.py", line 165, in _blocking_request
self._enqueue_notification)
File "/usr/local/lib/python2.7/site-packages/neovim/msgpack_rpc/async_session.py", line 65, in run
self._msgpack_stream.run(self._on_message)
File "/usr/local/lib/python2.7/site-packages/neovim/msgpack_rpc/msgpack_stream.py", line 43, in run
self._event_loop.run(self._on_data)
File "/usr/local/lib/python2.7/site-packages/neovim/msgpack_rpc/event_loop/base.py", line 134, in run
raise err
KeyboardInterrupt: Received SIGINT
nothing actually even happened until I send SIGINT (^C
)
Because of the asynchronous nature of the neovim-python client, inputting keys while another key is still processing can cause some weird timing bugs (though not always). Currently, the solution is to force v.tio to run slower, which is hardly an idea solution.
When you run the reverse command on a visual block, and then call gv
, it will select a line based selection on the last line instead of reselecting the entire block
There is no list of official commands. Currently the only place these are documented is in my brain. This would go well with a code-page.
When I use the -d
flag, I get this error:
Couldn't find the neovim executable! Is neovim installed?
What causes it, and why?
For example, look at this program:
ysw|Äx
Explanation:
ysw| "Surround this word in '|'
Ä "Duplicate this line
x "Delete a character
For some reason though, this deletes the character before duplicating the line. I'm guessing it's most likely a bug with the feedkeys
function putting the paste command in the wrong place in the keypress queue. The same issue comes up if you put the duplicate command in a macro. For example, this program:
i¸ 1 X 8 + 1 = 9�8ñYp|Eäl�^Xf+�$äl�
Clearly prints all the "ones" after the macro is done executing.
Currently, commands are implemented in python. This is a big problem since python doesn't have full access to the state of vim when the command starts. The simple obvious solution is to replace all of the python commands with vimscript commands. That will allow the python code to be simplified, since we won't need to track things like mode, and count.
Can you make a new chat-room please?
The /
and ?
commands don't allow a count before them, as nmjcman101 brought up in chat. While I'm at it, it might not heard to offer a count before the other regex commands.
In vim, using the arrow keys is one way to move around while in Insert-mode. Using them may sometimes save bytes, if you don't have to move too far and if you want to end up in the same mode as before (compare <Right>
with <C-o>l
, or <Right><Right><Right>
with <C-o>3l
)
Is there a way to incorporate arrow key presses in V-programs? I tried using <Right>
with the -v
flag, but that didn't work.
Control:
5é*
Count of 5, prints 5 asterisks
https://tio.run/##K/v/3/TwSq3////rlgEA
With :
5<M-->é*
Count of 5, decrement the count by 1 to get 4, but it only prints 1 asterisk
https://tio.run/##K/v/39TGV1fX7vBKrf///@uWAQA
Same thing with <M-+>:
5<M-+>é*
Count of 5, increment the count by 1 to 6, but it only prints 1 asterisk
https://tio.run/##K/v/39TGV1fb7vBKrf///@uWAQA
I tried testing with the actual character rather than the verbose mode, but it seems that the given character for on the wiki is just a regular -
character. I tried that, and an "–" (em dash), and I'm still not sure which is correct but both had the same effect anyways. I also tried «
for <M-+>, no difference either. It seems that the command is using up the count so the next command can't use it. I don't think this is intended behavior, as it wouldn't be a very useful command.
For example, <M-d><C-v>j
should behave the same as y<C-v>jP
, but it clearly doesn't.
According to Stasoid at PPCG(in the comments) the source of the slowness of V is the key_stroke() function in v.py. It includes a 100ms wait.
You can verify this by mapping one of those characters to something like:
iItworked!<esc>
and then trying to run a program with just this mapped character. Nothing will show up. This is a problem since 0x80-0x9F
was going to be mapped to regex shortcuts, e.g. \zs
, \ze
, {-}
, {1}, {2}, {3}, {4}...
, .*
, .+
, etc. as well as maybe some character classes. (Even/Odd digits, Vowels/consonants, maybe some others)
Similar to this issue, I decided to run Lynn's method on V answers.
Query used. Code:
import csv
import collections
digraphs = collections.Counter()
trigraphs = collections.Counter()
quadgraphs = collections.Counter()
cp1252 = "ǝʒαβγδεζηθ\nвимнтΓΔΘιΣΩ≠∊∍∞₁₂₃₄₅₆ !\"#$%&'()*+,-./0123456789" + \
":;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrst" + \
"uvwxyz{|}~Ƶ€Λ‚ƒ„…†‡ˆ‰Š‹ŒĆŽƶĀ‘’“”•–—˜™š›œćžŸā¡¢£¤¥¦§¨©ª«¬λ®¯°" + \
"±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëì" + \
"íîïðñòóôõö÷øùúûüýþÿ"
with open("QueryResults(2).csv", newline="", encoding="utf-8") as f:
for row in csv.reader(f):
if row[0] == "Post Link":
continue
code = row[1]
if "<pre><code>" not in code:
continue
# Extract the first bit of code
vyxal = (
code.partition("<pre><code>")[2]
.partition("</code></pre>")[0]
.strip()
)
vyxal = vyxal.replace(""", '"')
vyxal = vyxal.replace(">", ">").replace("<", "<")
vyxal = vyxal.replace("&", "&")
for i in range(0, 256):
vyxal = vyxal.replace("&#"+str(i)+";", cp1252[i])
vyxal = vyxal.replace("<esc>", cp1252[0x1b])
alpha = "abcdefghijklmnopqrstuvwxyz"
for idx, i in enumerate(alpha):
vyxal = vyxal.replace("<C-"+i+">", cp1252[idx+1])
vyxal = vyxal.replace("<M-x>", "ø")
if any(vyxal.count(c) >= 10 for c in vyxal):
continue
if len(vyxal) > 100:
continue
for line in vyxal.split("\n"):
for (a, b) in zip(line, line[1:]):
digraphs[a, b] += 1
for (a, b, c) in zip(line, line[1:], line[2:]):
trigraphs[a, b, c] += 1
for (a, b, c, d) in zip(line, line[1:], line[2:], line[3:]):
quadgraphs[a, b, c, d] += 1
with open("most-common.txt", "w", encoding="utf-8") as f:
f.write("2-graphs:\n")
for d, n in digraphs.most_common(30):
f.write("%4d %s\n" % (n, "".join(d)))
f.write("\n3-graphs:\n")
for d, n in trigraphs.most_common(30):
f.write("%4d %s\n" % (n, "".join(d)))
f.write("\n4-graphs:\n")
for d, n in quadgraphs.most_common(30):
f.write("%4d %s\n" % (n, "".join(d)))
Results (displayed in the 05AB1E codepage):
2-graphs:
24 Àñ
24 ./
21 Àé
21 @"
19 $x
17 xx
17 /
17
15 /&
15 dd
15 «©
14 Íî
14 òÍ
14 12
13 2i
13 lD
13 Gp
13 ll
13 é
12 Θ"
12 /d
12 /
12 Yp
11 r
11 lx
11 e
11 ₂
11 Ó.
11 òd
10 kl
3-graphs:
11 ./&
10 Ó./
8 [ae
8 aei
8 eio
8 iou
8 "qp
7 YGp
7 /&ò
7 lxx
7 $xh
7 D@"
6 Í./
6 xx>
6 Ä$x
6 qpx
6 Àé
5 Àé*
5 òͨ
5 Àñ
5 ou]
5 ¨ä«
4 ©î±
4 ¨[a
4 ]«©
4 «©¨
4 «©/
4 òÍî
4 /
4 /12
4-graphs:
8 [aei
8 aeio
8 eiou
8 Ó./&
6 ./&ò
6 "qpx
5 iou]
4 ¨[ae
4 òÄ$x
4 Ä$xh
4 ~"qp
4 :se
4 2i2i
4 ¨ä«©
3 Í./&
3 ¨.«©
3 lxx>
3 iouy
3 ouy]
3 uy]«
3 À|lD
3 Ñ~"q
3 ./&
3 òhYp
3 hYpX
3 :sor
3 éiD@
3 iD@"
3 ₂"qp
3 gÓul
Right now, V heavily relies upon unprintable characters. For example, this program: http://v.tryitonline.net/#code=AQEBAQEBAQEBAQ&input=MTA
Nobody can tell what this code will do without running it.
This is OK since TIO handles them really well, and they're perfectly visible from in vim, but not everybody will write V code in vim. We should come up with a way to map certain printable unicode characters to the unprintable ones just for convenience so that other users can copy and paste commands from the docs, rather than being forced to write it in vim.
This will also make it easier to tell the flow of the program just by looking at it.
The following produces the lowercase alphabet in neovim, but the string character |linewise|.
in V:
:h<_<CR>jjYZZp
I tested a different help page, which consistently produces *usr_01.txt* Nvim
in both "languages":
:help tutor<CR>ggYZZp
Neovim is poorly supported on windows (not sure about mac). It would be nice to have it run on vim 8 instead of neovim for portability. This will require moving some logic into a vimscript "main function" of sorts, but I think that's OK. Doing that would probably also fix the timing bug
os_code.py
opens xterm
to run V programs in debug mode for both Linux and Mac. However, in macs xterm
by default is an unknown command since it is not pre-installed.
elif args["platform"] == "Linux":
command = "xterm -e 'nvim -n -i NONE -u nvim/init.vim "
All I'm suggesting is that there be a statement to check if the platform is macOS and then runs the program without calling xterm
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.