-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocumentation.py
More file actions
1707 lines (1540 loc) · 79.8 KB
/
documentation.py
File metadata and controls
1707 lines (1540 loc) · 79.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
This is a help document for using RP's pseudo_terminal.
SUMMARY
This documention is for RP (aka RyanPython).
It's not totally organized yet, but you can search through it to find what you want.
It's not yet complete, but includes a lot of important information.
It's an extension of the HELP command.
If you have any questions, you can email sqrtryan@gmail.com (for Ryan Burgert, the author of this package)
Note: The only reason this is a .py file and not a .txt file is to make it conveniently be included in my pypi package. It's not an actual python file. This might change in the future.
Important Backslash Commands:
\da \co \pa \vi \tbp \23p \ya \sw \tts \lo \sa \pu
SOME FEATURES OF RP:
NORMAL FEATURE LIST:
A profiler
Debugger
Better stack traces
Code autoformatter
Super fast Autocompletion
Syntax highlighting
Multi-line editing
Linecaching (useful for debugger and stack traces)
Xonsh shell (cross-platform)
Auto re-import modules
Embeddable pseudo_terminal()
Runs with or without tty
Persistent history and settings (even when updating rp)
SPECIAL FEATURE LIST:
Introspection tools ? ?. etc
Big matlab-like library
Microcompletions
ans, PREV, UNDO, etc
Tons of pretty themes
COOL THINGS TO NOTICE:
Invariant to prompt_toolkit version. This should run anywhere fine. (Todo: Make it have 0 dependencies)
rp includes a lot of tools made by different people. But the thing is, mine works out-of-the-box, no setup required. It makes these tools easy and accessible, as simple as 'pip install rp'.
KEY KEY:
// In this documentation, you might see non-ascii symbols such as ↵ or ⌥. These symbols represent keys that can't otherwise be represented with a signle character.
// This section is a key to tell you which symbol corresponds to which key, which will be useful for later sections of this documentation.
// https://apple.stackexchange.com/questions/55727/where-can-i-find-the-unicode-symbols-for-mac-functional-keys-command-shift-e/55729
↵ = '\n' aka the enter key
¦ = the cursor
⌫ = backspace
⌦ = delete
⇧ = shift
⌥ = alt/option (assumed to be an escape prefix)
⌘ = command
⌃ = control
⇥ = tab
← = left arrow key
→ = right arrow key
↓ = down arrow
↑ = up arrow
␣ = spacebar
⎋ = escape
KEYBOARD SHORTCUTS:
⌃ c copy
⌃ v paste
⌃ d duplicate current line
⌃ e execute current cell and keep buffer
⌃ w run current cell and keep buffer
⌃ q cancel current buffer
⌃ l clear and redraw the current screen (this is also useful when the gui looks all messed up, like if something printed over the gui for whatever reason)
⌃ ⌦ delete current line
⇧ → move cursor to far right of line or shift line down
⇧ ← move cursor to far left of line or shift line up
⌥ ↵ run current cell and clear buffer no-matter where you cursor is
⇧ ⇥ unindent current line or cycle through completions
⌃ ␣ toggle comment on current line and move cursor to next line
⌥ X delete the first character of every line
⌥ v edit current text in vim (equivalent to the \vi microcompletion)
⌥ ␣ forcibly insert a space character, skipping any microcompletions
⌥ ⌫ backspace a whole word
⌥ ← jump back one word
⌥ → jump forward one word
⌥ ↓ jump down 10 lines
⌥ ↑ jump up 10 lines
⌥ ! run shell command
⌥ # comment out the entire buffer and run that comment (it will do nothing lol)
⌥ n executes 'NEXT', changing the value of 'ans' (useful in combination with \rpa and \an)
⌥ p executes 'PREV', changing the value of 'ans' (useful in combination with \rpa and \an)
⌥ r similar to \rpa, except it clears the buffer. Sets ans to the current buffer as a string
⌃ a insert str(ans) Equivalent to \an
⌥ ⌃ a insert repr(str(ans)) Equivalent to \sa
⌥ q equivalent to \da: clears the current buffer
⌥ ( insert ( at current position and ) at the end of the line without moving the cursor to the end of the line
⌥ [ insert [ at current position and ] at the end of the line without moving the cursor to the end of the line
⌥ ) insert ) at the end of the line without moving the cursor to the end of the line
⌥ ] insert ] at the end of the line without moving the cursor to the end of the line
⌥ { insert { at current position and } at the end of the line without moving the cursor to the end of the line
⌥ } insert } at the end of the line without moving the cursor to the end of the line
⌃ t loads previous buffer in history regardless of where cursor is (stands for top). Faster than spamming the up arrow key
⌃ b loads next buffer in history regardless of where cursor is (stands for bottom). Faster than spamming the down arrow key
⌃ z undo last action
⌃ y redo last undone action
⌥ ⌃ e Edit code with AI
REFACTORING:
⌃ r extract variable (requires selection: select expression, press ⌃r, type name, Enter)
⌃ n rename variable at cursor (place cursor on variable name, press ⌃n, type new name, Enter)
⌃ p inline variable at cursor (place cursor on assignment or usage, press ⌃p to inline)
< move element left in syntax tree (requires selection: select arg/element, press <)
> move element right in syntax tree (requires selection: select arg/element, press >)
⌥ ⇧ ↑ expand selection to larger AST node (select text, press to expand to parent node)
⌥ ⇧ ↓ contract selection to smaller AST node (select text, press to shrink to child node)
F1 enable/disable mouse mode
F4 toggle between Vi and Emacs mode
F5 save F2 menu settings (when sidebar is visible)
F6 enable/disable paste mode
F7 enable/disable line wraps
F8 enable/disable microcompletions
LESS IMPORTANT AND MAYBE REMOVED IN FUTURE:
//While these keyboard shortcuts are kind of silly, I do find myself using them quite often
⌃ h inserts 'HISTORY'
⌃ u inserts 'UNDO'
⌥ m inserts 'MORE' (then 'MMORE', if pressed again)
⌥ s inserts 'self'
⌥ ⌃ v edit current text in vim (equivalent to the \vi microcompletion)
MICROCOMPLETIONS:
//This section covers only the microcompletions that take place in the context of a single line
BACKSLASH COMMANDS:
WITH ARGUMENTS:
\sa save file (used like ‹`file.py\sa›. Saves the current buffer to 'file.py'. Will create a backup file if we overwrite something.)
\wr write file (used like ‹`file.py\wr›. Saves the current buffer to 'file.py'. Not as safe as save file, because it will not create a backup file when overwriting.)
\lo load file (used like ‹`file.py\lo›. Loads 'file.py' into the current buffer)
\re replace (used like ‹`old`new\re›. It's a search-and-replace)
\rre replace varname (like \re but specifically for replacing variable names with proper scoping)
\py python (used like ‹`repr\py›, ‹`str.upper\py›, or ‹`print_fix\py› etc. Replaces current buffer's text with function(currenttext))
\go goto (used like ‹`10\go›. Bring the cursor to that line number.)
\dtl delete to line (used like ‹`5\dtl›. Like d5G in vim.)
\ca cancel (cancels any command you would have written and deletes the arguments. More civilized than spamming undo or backspace.)
\?c source code (will enter the source code of any expression given in the first argument. Can also be used with no `s, where the entire buffer is the expression)
\/c source code (is an alias for ?c)
WITHOUT ARGUMENTS:
\lo load file (loads a file just like `file.py\lo does, except it opens a dialog to let you choose the file so you dont have to type it manually)
\db debugger (toggles the existence of 'debug()' on the top of your prompt without moving your cursor)
\pu pudb (other debugger) (similar to \db, pudb is an alternative debugger, and this command also toggles a line on the top of the buffer. Whether you use this or \db is a matter of prefernece.)
\vi vim (opens up the current buffer in vim. Edit your code, then save the temp file and close vim. Your cursor's position will be shared between vim and rp.)
\mi micro (opens up the current buffer in micro editor. Similar to \vi but uses the micro editor.)
\na nano (opens up the current buffer in nano editor. Similar to \vi but uses the nano editor.)
\ed editor (opens up the current buffer in some text editor; might be nano, might be vim. Depends on what you have. This command is an alternative to \vi)
\ac align char (inserts ‹→›, aka the alignment character. Used before \al. See https://asciinema.org/a/KjFS2lT0shRyv4r82RtFENzlo)
\al align (aligns all alignment characters to the same column. Used after inserting \ac in multiple different places.)
\co copy (copies the current buffer to your clipboard)
\pa paste (equivalent to control+v)
\spa string paste (pastes current clipboard as a python string literal)
\3pa commented paste (pastes current clipboard, but commented out. Can also use this command with arguments: ` \3pa makes comments with four spaces of indentation, for example.)
\wco web copy (applies WCOPY to the current buffer's string. Use this to copy text between computers)
\wpa web paste (inserts the output of WPASTE at your cursor position. Use this to paste text from another computer.)
\wspa web string paste (inserts the output of repr(WPASTE) at your cursor position. Use this to paste text from another computer.)
\lco local copy (same as \wco except it uses LCOPY instead of WCOPY )
\lpa local paste (same as \wpa except it uses LPASTE instead of WPASTE)
\lspa local string paste (same as \wspa except it uses LCOPY instead of WCOPY )
\tco tmux copy (applies TCOPY to the current buffer's string. Use this to copy text to a tmux session)
\tpa tmux paste (inserts the output of TPASTE at your cursor position. Use this to paste text from a tmux session. This is useful because often tmux will press the enter key when pasting a multiline string.)
\tspa tmux string paste (inserts the output of repr(TPASTE) at your cursor position. Use this to paste text from a tmux session. This is useful because often tmux will press the enter key when pasting a multiline string.)
\t3pa tmux commented paste (inserts the output of TPASTE, but commented out. See \3pa for more information.)
\vco vim copy (applies VCOPY to the current buffer's string. Use this to copy text to vim's default register)
\vpa vim paste (inserts the output of VPASTE at your cursor position. Use this to paste text vim's default register)
\vspa vim string paste (inserts the output of repr(VPASTE) at your cursor position. Use this to paste text vim's default register as an escaped string)
\an ans (inserts str(ans) at current cursor position)
\3an commented ans (inserts str(ans), but commented out. See \3pa for more information.)
\sa string ans (inserts repr(ans) at current cursor position)
\da delete all (deletes all text in the current buffer)
\sw strip whitespace (strips all trailing whitespace in the buffer)
\sc strip comments (removes all #comments in the buffer)
\sbl strip blank lines (removes all blank/empty lines from the buffer)
\stp strip (strips leading/trailing whitespace from entire buffer text)
\spl splitlines (converts buffer to Python list format with one line per element)
\lj line join (joins Python list format back to lines)
\rcl reverse columns (reverses each line character-by-character)
\d0l delete empty lines (removes empty lines in the buffer. d0l means there can be 0 consecutive empty lines)
\d1l delete empty lines (1) (allows max 1 consecutive empty line)
\d2l delete empty lines (2) (allows max 2 consecutive empty lines)
\d3l delete empty lines (3) (allows max 3 consecutive empty lines)
\d4l delete empty lines (4) (allows max 4 consecutive empty lines)
\d5l delete empty lines (5) (allows max 5 consecutive empty lines)
\d6l delete empty lines (6) (allows max 6 consecutive empty lines)
\d7l delete empty lines (7) (allows max 7 consecutive empty lines)
\d8l delete empty lines (8) (allows max 8 consecutive empty lines)
\d9l delete empty lines (9) (allows max 9 consecutive empty lines)
\rl reverse lines (reversed the order of all lines of text in the buffer)
\sl sort lines (sorts all lines in the buffer in alphabetical order)
\ya yapf autoformatter (autoformats your current code buffer using google's yapf library)
\bla black autoformatter (autoformats your current code buffer using the 'black' library: pypi.org/project/black )
\sim sort imports (sorts and organizes all imports in the current buffer, using the 'isort' library)
\cim clean imports (removes unused imports using the 'unimport' library)
\rms remove star (turns all 'from x import *' into explicit 'from x import y,z,...' etc)
\rmfs remove f-strings (converts f-strings to .format() calls)
\fn function name (writes the name of the current function)
\gg go to top (like gg in vim. bring cursor to the top of the buffer)
\GG go to bottom (like G in vim. bring cursor to the bottom of the buffer)
\vO insert line above (like O in vim. Inserts a new line above the current line.)
\vo insert line below (like o in vim. Inserts a new line below the current line.)
\mla multi line arguments (turns a lengthy def into a multi line def. See https://asciinema.org/a/RHuWRKsbwvkH3P28XZ81MnFYJ)
\tbp toggle big parenthesis (enables/disables using big parenthesis on a given line https://asciinema.org/a/jhxmIcRogKp4yJy1gojIZBAem)
\tts tabs to spaces (turns all tabs in the buffer into 4 spaces)
\23p python 2 to 3 (converts python2 code to python3 code: "print raw_input('>>>')") --> "print(input('>>>'))")
\fo for-loopify (envelops the whole buffer into a for loop. Useful for when you have a command but just want to run it over without DITTO, which pollutes HISTORY)
\wh while-loopify (envelops the whole buffer into a 'while True' loop. Useful for when you have a command but just want to loop it indefinitely)
\de functionify (envelops the whole buffer into a function body)
\inm if name main (inserts 'if __name__ == "__main__":' block)
\lss LS SEL (lets you select a file or folder and inserts the absolute path as a string)
\lsr (Relative) LS SEL (lets you select a file or folder and inserts the relative path as a string)
\rpr repr (is equivalent to `repr\py It will turn your buffer into a string literal)
\fi from import swap (when you're on a line that goes like "from x import y", turns it into "import x". Vice versa.)
\en enumeratify (Use when in a for-loop block header. Turns whatever it is into enumerated form. For example, ‹for x in y:› to ‹for |,x in enumerate(y):)
\rpa repr to ans (sets ans to the current buffer's text)
\lg load gist (treats the current buffer as a Github Gist URL, and tries to load it into the buffer. If it's a git.io shortened url, you only need to specify the title (for example, if using git.io/A3FC you can just use A3FC))
\sg save gist (saves the current buffer as a Github Gist and sets 'ans' to the url of the gist)
\dtb delete to bottom (deletes all lines below the cursor. Useful for getting lines after something like CHIST then \pa)
\dtt delete to top (deletes all lines above the cursor. Useful for getting lines after something like CHIST then \pa)
\dgx deepgenx (auto-completes your code using deepgenx. See https://deepgenx.com/. It's like GitHub Copilot, except open source and made with GPT-J. Needs internet.)
\gpt gpt3 (auto-completes your code with gpt3. Needs internet. Mostly just for fun...but might have good uses.)
\min minify (Minifies your code - making it as small as possible. Uses https://github.com/dflook/python-minifier)
\sdo strip docstrings (Removes all docstrings from your code)
\irp inline rp stuff (Works iteratively. Will inline anything in your code from rp, assuming it was coming from the implicit 'from rp import *'. Use it repeatedly, until you've gone deep enough.)
\qrp qualify rp (Makes rp imports explicit by qualifying them with the rp module prefix)
\ev extract variable (Extracts selected code into a separate variable assignment)
\und unindent (Decreases indentation of all lines in buffer)
\ind indent (Increases indentation of all lines in buffer)
\wi working index (Inserts buffer working index comment)
\dipa diff paste (Shows diff between buffer and pasted content)
\ditp diff tmux paste (Shows diff between buffer and tmux clipboard)
\divp diff vim paste (Shows diff between buffer and vim clipboard)
\diwp diff web paste (Shows diff between buffer and web URL content)
\dian diff ans (Shows diff between buffer and last answer value)
\dilp diff local paste (Shows diff between buffer and local file)
\diph diff pt history (Shows diff from prompt_toolkit history)
\qph query pt history (Queries prompt_toolkit history)
FOR LOOPS:
COMPREHENSION:
IF: [f ff f ff] –––> [f for f in f if f]
IF: [f ff f if] –––> [f for f in f if f]
‹[x fx y]› ––> ‹[x for x in y]›
CONTROL FLOW:
‹fo ,› ––> ‹for i,e in enumerate()› //, to enumerate
‹fo 5› –––> ‹for _ in range(5)› // 5 to range <––– these are shared in different places
‹for hello-world› –––> ‹for hello_world in :›// - to _ immediately
‹fo -e a› ––> ‹for _ in enumerate(a)›
‹fo -r a› ––> ‹for _ in range(a)›
‹fo -l a› ––> ‹for _ in range(len(a))›
‹fo -z a› ––> ‹for _ in zip(a)›
‹fo x › ––> ‹for x in ans›
space to english plurality
space to context variable
KEYWORD COMPLETIONS:
IF ELSE:
x=y fz q
EDGE CASES:
[f ff f if] –/–> [f for f in f if f else]
LETTER TO OPERATOR:
in or and if/else,...
AUTO SPACES:
in, is, as
CONTROL FLOW:shorturl.at/oIY16
ON ENTER:
try,else,elif,def,...
try: except as: pass
with: as:
ON SPACE:
try,else,elif,def,...
ASSERTIONS:
PRINT: Not technically a keyword but kinda sorta is...it was in py2
DECORATORS:
‹2memoized› –––> ‹@memoized›
‹2memoized↵df›–––> ‹@memoized↵def f():›
‹2memoized↵cf›–––> ‹@memoized↵class f:›
FUNCTIONS:
everything from args to the pass
CLASSES:
‹c Name› –––> ‹class Name¦:›
‹c Name object› –––> ‹class Name(object¦):›
‹c Name object int› –––> ‹class Name(object,int¦):›
QUICK KEYWORDS:
‹c↵› –––> ‹class _:
¦› //Only if we're not directly in a for/while loop
‹c › –––> ‹class ¦:›
‹c↵› –––> ‹continue↵› //Only if we are directly in a for/while loop
‹b › –––> ‹break ›
‹b↵› –––> ‹break↵›
‹c › –––> ‹class ¦:›
‹a › –––> ‹assert ¦:›
‹g › –––> ‹global ¦›
‹n › –––> ‹nonlocal ¦›
‹r › –––> ‹return ¦› //Only if we're inside a function
‹ra › –––> ‹raise ¦›
‹r↵› –––> ‹return↵¦› //Only if we're inside a function
‹y↵› –––> ‹yield↵¦› //Only if we're inside a function
‹y › –––> ‹yield ¦› //Only if we're inside a function
‹y › –––> ‹yield from ¦› //Only if we're inside a function
‹p › –––> ‹print(¦)› //Even though print isn't a keyword in python 3, it was in python 2. This is also a completion.
‹p↵› –––> ‹pass↵›
‹i↵› –––> ‹if True:
¦›
‹i › –––> ‹if ¦:› //Only if we're not on the first line (we're more likely to import as a command than start our buffer with an 'if' branch)
‹i › –––> ‹import ¦› //Only if we are on the first line
‹if › –––> ‹if ¦:›
‹im › –––> ‹import ¦›
‹l › –––> ‹lambda ¦:›
‹w↵› –––> ‹while True:
¦›
‹w › –––> ‹while ¦:›
‹wi › –––> ‹with ¦:›
‹wi x › –––> ‹with x as ¦:›
‹f↵› –––> ‹for _ in ans:
¦›
‹f › –––> ‹for ¦ in :› //Only if we're not on the first line
‹f › –––> ‹from ¦ import› //Only if we are on the first line, otherwise f makes a for loop
‹fo › –––> ‹for ¦ in :› //This works regardless of the line we're on
‹fr › –––> ‹from ¦ import› //This works regardless of the line we're on
‹d↵› –––> ‹def ans():
¦› //Only if we're not inside a class
‹d › –––> ‹def ¦():› //Only if we're not inside a class
‹d↵› –––> ‹def __init__(self):
¦› //Only if we are inside a class
‹d › –––> ‹def ¦(self):› //Only if we are inside a class
‹t › –––> ‹try:¦›
‹t↵› –––> ‹try:
¦›
‹ex › –––> ‹except ¦:›
On ‹↵›: ‹try: –––\ ‹try:
pass \ pass
e¦› / except:
–––/ ¦›
On ‹ ›: ‹try: ‹if x:
pass –––> pass
ex¦› except ¦:›
//Each transition arrow is another successive press of the spacebar
On ‹ ›: ‹try: ‹try: ‹try: ‹try:
pass –––> pass –––> pass –––> pass
ex¦ except:¦› except:¦› except:pass¦›
On ‹↵›: ‹if x: –––\ ‹if x:
y \ y
e¦› / else: //enter to else
–––/ ¦›
On ‹ ›: ‹if x: ‹if x: ‹if x:
y –––> y –––> y //space to elif to else
e¦› elif ¦:› else:¦›
FUNCTION DEFINITIONS:
‹d › –––> ‹def ¦():› //Only if we're not inside a class
‹d f x› –––> ‹def f(x¦):› //Only if we're not inside a class
‹d f x y› –––> ‹def f(x,y¦):› //Only if we're not inside a class
‹d › –––> ‹def ans(¦):› //Only if we're on the first line
‹d › –––> ‹def _(¦):› //Only if we're not on the first line and not inside a class
‹d › –––> ‹def ¦(self):› //Only if we are inside a class
‹d f › –––> ‹def f(self,¦):› //Only if we are inside a class
‹d f x y› –––> ‹def f(self,x,y¦):› //Only if we are inside a class
CLASS DEFINITIONS:
‹c x › –––> ‹class x(¦):›
‹c x y z› –––> ‹class x(y,z¦):›
ANS:
. to ans.
space to ans() or ans[] or ans
for x in space --> for x in ans (duplicate entry)
space-function f(ans,ans,ans,ans) (duplicate entry)
x+ --> x+ans
*5 –––> ans*5
MISC:
''''. –––> ''.join(|)
;\n –––> new line
On ?: print(x[thing¦]) –––> print(x[thing])?¦ //Don't have to move cursor to use inspection ?'s
On \n: ans[5/¦] –––> ans[5]?\n¦
On ‹-›: ‹def func(x,y,z)¦:› –––> ‹def func(x,y,z)->¦:› // - goes to -> in functions
On ‹-›: ‹def func(x,y,z)->¦:› –––> ‹def func(x,y,z)->¦:› // nothing happens
On ‹>›: ‹def func(x,y,z)->¦:› –––> ‹def func(x,y,z)->¦:› // nothing happens
MATRIX LITERALS:
[[1,2,3],[4,5,6],[7,8,9]]
INDEXING:
ASSIGNMENT SHORTCUT:
x[1=y] –––> x[1]=y
SPACE INSTEAD OF RIGHT ARROW KEY:
x[y ,z] –––> x[y],z
SPACE
x[1 2 3]–––>x[1][2][3]
DOTS
x..y –––> x['y']
x.3 –––> x[3]
SPACE FUNCTIONS:
f(f(f(f())))
list map int ans
f(ans,ans,ans,ans,ans,ans) (duplocate)
space-function option in r.py that comlpetes without tab
LAMBDAS:
‹lambda 1› –––> ‹lambda:1¦›
‹l 1› –––> ‹lambda:1¦›
‹l › –––> ‹lambda:None¦›
‹l x x+1› –––> ‹lambda x:x+1¦›
‹l x y x+y› –––> ‹lambda x,y:x+y¦›
‹lambda x y x+y› –––> ‹lambda x,y:x+y¦›
REORDERING:
//Use < and > to swap the order of comma-separated values.
//Use in function declarations, lists, tuples – you name it!
//Right now the implementation isn't perfect, but it's usually good enough
//It works because [x,<y] is invalid syntax
LEFT:
On ‹<›: ‹[alpha,beta,¦gamma]› –––> ‹[alpha,¦gamma,beta]› //This hopefully makes intuitive sense
On ‹<›: ‹[alpha,¦gamma,beta]› –––> ‹[gamma,¦alpha,beta]› //The position of the cursor doesn't change because it should remain next to a comma, and there are no more commas to the left
On ‹<›: ‹def f(bob,sam,¦ann,tim):› –––> ‹def f(bob,¦ann,sam,tim):›
RIGHT:
//You should get the idea by now... < goes left and > goes right...
On ‹>›: ‹[alpha,¦beta,gamma]› –––> ‹[alpha,gamma,¦beta]›
IMPORTS:
FROM:
On ‹ ›: ‹f¦› –––> ‹from ¦ import› //True iff single-line command
On ‹ ›: ‹fr¦› –––> ‹from ¦ import› //f, fr, and fro are all microcompleted into from
On ‹ ›: ‹from¦› –––> ‹from ¦ import›
On ‹ ›: ‹from npy¦ import› –––> ‹from numpy import ¦› //npy was autocompleted to numpy. Of course, whether this works depends on the context of your completion menu.
On ‹ ›: ‹from numpy¦ import› –––> ‹from numpy import ¦›
On ‹ ›: ‹from numpy import ¦› –––> ‹from numpy import *¦› //Import all
On ‹ ›: ‹from numpy import *¦› –––> ‹from numpy import ¦›
On ‹ ›: ‹from numpy import ndarray¦› –––> ‹from numpy import ndarray as¦›
On ‹ ›: ‹from numpy import ndarray as array¦› –––> ‹from numpy import ndarray as array, ¦›
On ‹⌫›: ‹from ¦ import› –––> ‹¦› // Delete it as quickly as you created in-case you didn't mean to import anything afterall
‹f a b c d e f g› –––> ‹from a import b as c, d as e, f as g¦› //This doesn't take into account autocompletions, but you get the general idea...
IMPORT:
On ‹ ›: ‹i¦› –––> ‹import ¦› //True iff single-line command
On ‹ ›: ‹im¦› –––> ‹import ¦› //i, im, imp, impo, and impor are all microcompleted into import upon pressing space
On ‹ ›: ‹import npy¦› –––> ‹import numpy as ¦›
On ‹ ›: ‹import numpy¦› –––> ‹import numpy as ¦›
On ‹ ›: ‹import numpy as np¦› –––> ‹import numpy as np, ¦›
On ‹ ›: ‹import numpy as np¦› –––> ‹import numpy as np, ¦›
On ‹ ›: ‹import numpy as np, time¦› –––> ‹import numpy as np, time as ¦›
On ‹↵›: ‹import numpy as¦› –––> ‹import numpy↵¦› //'import numpy as' is invalid syntax for a line of code
IMAGINARY OPERATORS:
--: x-- –––> x-=1
++: x++ –––> x+=1
..: x..y..z –––> x['y']['z']
.: x.1.2 –––> x[1][2]
[=: x[=y –––> x=x[y]
(=: x(=y –––> x=x(y)
]=: x]=y –––> x=y[x]
)=: x)=y –––> x=y(x)
.=: x.=y –––> x=x.y
=.x: x=.y –––> x.y=y
..=: x..=y –––> x.y=x
=..: x=..y –––> x=y.x
nin: x nin y –––> x not in
isnt: x isnt y –––> x is not y
snt: x snt y –––> x is not y
n: x n y –––> x in y
o: x o y –––> x or y
a: x a y –––> x and y
s: x s y –––> x is y
EDGE CASES:
for x nin y: –/–> for x not in y:
=]:(Not implemented)
COMPARATORS:
DRAGGING:
On ‹=›: ‹f(x==¦)› –––> ‹f(x)==¦›
f(x>==) ---> f(x)>=
f(x<==) ---> f(x)<=
f(x===) ---> f(x)==
f(x!==) ---> f(x)!=
f(x>>) ---> f(x)>
f(x<<) ---> f(x)<
EQUALITY:
//Instead of =, insert ==
On ‹=›: ‹if x¦:› –––> ‹if x==¦:›
On ‹=›: ‹assert x¦:› –––> ‹if x==¦:›
EDGE CASES:
On ‹=›: ‹x=y¦› –/–> ‹x=y==¦:›
On ‹=›: ‹x=y¦› –––> ‹x=y=¦:› //x=y=z is valid, commonly used syntax
On ‹=›: ‹if f(x¦):› –/–> ‹if f(x==¦):›
On ‹=›: ‹if f(x¦):› –––> ‹if f(x=¦):› //Keyword arguments, like f(x=1), use a single == instead of a double ==
INEQUALITY:
//(See INEQUALITIES under SHIFT SAVERS)
SHIFT SAVERS:
//When possible, avoid having to press the shift key
INEQUALITIES:
//Where possible, turn .= to >= and ,= to <=
//This saves you the bother of pressing the shift key
On ‹=›: ‹if x,¦:› –––> ‹if x<=¦:› //Note that although ‹if x,=y:› is valid syntax, it's weird to compare a tuple to y in this way, and most of the time we're probably better off turning x,= into x<=
On ‹=›: ‹if x.¦:› –––> ‹if x>=¦:› //Note that even though we talked about the imaginary '.=' operator, it doesn't make sense in this context, so it's ok to run .= into >=
On ‹=›: ‹print(x,¦)› –––> ‹print(x<=¦)›
On ‹=›: ‹print(x.¦)› –––> ‹print(x>=¦)›
EDGE CASES:
‹x.=y› –––> ‹x=x.y¦›
‹x.=y› –/–> ‹x>=y¦›
COLON:
//When possible, turn ';' into ':'.
SLICING:
//In particular, you will often want to use ; to : when writing things like x[:5] or x[::-1].
‹x[;]› –––> ‹x[:]›
‹x[1;]› –––> ‹x[1:]›
‹x[i;]› –––> ‹x[i:]›
‹x[;;-1]› –––> ‹x[::-1]›
‹x[1;2;3]› –––> ‹x[1:2:3]›
‹x[a;b;c]› –––> ‹x[a:b:c]›
‹x[1;2,3;4]› –––> ‹x[1:2,3:4]›
ARGUMENT TYPE HINTS:
On ‹;›: ‹def f(x|):› ---> ‹def f(x:|):›
DICT LITERALS:
On ‹;›: ‹{x|}› ---> ‹x:|›
UNDERSCORE:
//When possible, turn - into _. This is a recurring motif in other completions as well.
FOR:
On ‹-›: ‹for ¦ in:› –––> ‹for _ in ¦:› //Although ‹for ¦ in:› seems like a strange starting point, note that other completions can take you there
On ‹-›: ‹[for ¦ in]› –––> ‹[for _ in ¦]›
FUNCTION CALL ARGUMENT:
On ‹↵›: ‹print(-)› –––> ‹print(_)›
On ‹↵›: ‹print(x,-)› –––> ‹print(x,_)›
On ‹)›: ‹print(-¦› –––> ‹print(_)¦› //TODO
On ‹,›: ‹print(-¦)› –––> ‹print(_,¦)›
On ‹ ›: ‹print(-¦)› –––> ‹print(_,¦)›
DECLARATION:
‹var-name-with-underscores=5› –––> ‹var_name_with_underscores=5›
‹def -func-name-(arg-1,-arg-2,-,--):› –––> ‹def _func_name_(arg_1,_arg_2,_,__):›
‹lambda -x,y-:None› –––> ‹lambda _x,y_:None› //TODO
On ‹-›: ‹def f(): –––\ ‹def f():
var¦› –––/ var_¦› //Why would you start a line in a function with an expression like x-y? That seems fairly useless, almost all the time. Instead, turn - into _ without having to double-tap
EDGE CASES:
‹x--› –/–> ‹x__› //This is because of a different microcompletion: the -- operator, which makes ‹x--› –––> ‹x-=1¦›
GLOBAL NONLOCAL DEL IMPORT:
//A - is a syntax-braking character inside del, import, global or nonlocal. Turn it into an underscore.
‹del x-,-y,-› –––> ‹del x_,_y,_¦›
‹global x-,-y,-› –––> ‹global x_,_y,_¦›
‹nonlocal x-,-y,-› –––> ‹nonlocal x_,_y,_¦›
‹import x-,-y,-› –––> ‹import x_,_y,_¦›
‹from - import -› –––> ‹from _ import _¦›
DOUBLE TAP:
//Instead of pressing shift and - to get _, you can often just press - twice
On ‹-›: ‹f(-¦)› –––> ‹f(_¦)›
‹print(----)› –––> ‹print(__¦)›
SPACEBAR:
‹if - in l:› –––> ‹if _ in l:¦›
‹while - in l:› –––> ‹while _ in l:¦›
‹x and - › –––> ‹x and _ ¦›
On ‹ ›: ‹if -¦:› –––> ‹if _ ¦:›
On ‹ ›: ‹while -¦:› –––> ‹while _ ¦:›
On ‹ ›: ‹x and -¦:› –––> ‹x and _ ¦:›
On ‹ ›:‹[-|]› --> ‹[_ |]›
EDGE CASES:
‹x- › –/–> ‹x_ ¦›
‹x- › –/–> ‹x_ ¦›
‹f()- › –/–> ‹f()_ ¦›
COMBOS:
On ‹ ›: ‹print(-¦)› –––> ‹print(_,¦)›
On ‹ ›: ‹if -¦ else› –––> ‹if _ else ¦›
OPERATORS:
//-*2 is invalid syntax, but _*2 is
‹-*› –––> ‹_*¦›
‹-+› –––> ‹_+¦›
‹-[0]› –––> ‹_[0]¦›
(MORE TO COME: There are definitely more places we should put this type of completion that have neither been implemented nor listed here)
NUMBERS TO CHARACTERS:
1:
//When possible, treat ‹1› as either ‹!› or ‹not›
!=:
//Here, we treat ‹1› like ‹!› when using ‹=› to get ‹!=›
‹x 1=› –––> ‹x !=¦›
‹if x 1= y› –––> ‹if x != y¦›
‹f()1=› –––> ‹f()!=¦›
‹[a 1= 2]› –––> ‹[a != 2]¦›
EDGE CASES:
//When turning ‹1› into ‹!=› would break syntax, don't do it
‹x and 1=› –/–> ‹x and !=¦› //Don't do it after a keyword...
‹if 1=› –/–> ‹if !=¦›
‹a=1==2› –/–> ‹a=!=2¦›
‹[1==2]› –/–> ‹[!=2]¦›
‹(1==2)› –/–> ‹(!=2)¦›
‹{1==2}› –/–> ‹{!=2}¦›
‹1j› –/–> ‹not j¦› //1j is a valid literal
not:
//Because we sometimes treat ‹1› like ‹!›,
// and we sometimes treat ‹!› like ‹not›,
// when possible, treat ‹1› as ‹not›
‹if 1y:› –––> ‹if not y:¦›
‹x and 1y› –––> ‹x and not y›
‹x and 1[]› –––> ‹x and not [¦]›
‹[x,1y]› –––> ‹[x,not y]¦›
‹f(1y)› –––> ‹f(not y)¦›
‹while 1f():› –––> ‹while not f():¦›
EDGE CASES:
‹while 1:› –––> ‹while 1:¦›
‹while 1:› –/–> ‹while not :¦›
‹while 12:› –––> ‹while 12:¦›
‹while 12:› –/–> ‹while not 2:¦›
‹while 1.:› –––> ‹while 1.:¦›
‹while 1.:› –/–> ‹while not .:¦›
‹while 1+2:› –/–> ‹while not +2:¦›
‹[x,1]› –––> ‹[x,1]¦›
‹[x,1]› –/–> ‹[x,not ]¦›
! and !!:
//Because pseudo-terminal treats ‹!echo hello› as a shell command, we treat 1 as ! and 11 as !! so that we don’t need to press the shift key.
//Note that this completion only occurs if the 1's are the first characters in the entire text buffer (! and !! have no effect anywhere else)
‹11pwd› –––> ‹!!pwd¦›
‹1pwd› –––> ‹!pwd¦›
‹1echo hello› –––> ‹!echo hello›
‹11echo hello› –––> ‹!!echo hello›
EDGE CASES:
‹1› –/–> ‹!¦›
‹11› –/–> ‹!!¦›
‹111› –––> ‹111¦›
‹111› –/–> ‹!11¦›
‹111› –/–> ‹!!1¦›
2:
//When applicable, treat ‹2› as ‹@› in the context of a function or class decorator
//To trigger, the ‹2› must be at the start of a line, ignoring whitespace. The pressed key must be a letter or underscore (a character capable of starting a variable name).
‹2memoized› –––> ‹@memoized¦›
‹ 2memoized› –––> ‹ @memoized¦›
EDGE CASES:
‹2› –/–> ‹@¦›
‹22memoized› –/–> ‹@2memoized¦›
‹§2memoized› –/–> ‹§@memoized¦› where ‹§› is any character other than ‹ ›
3:
//When possible, treat ‹3› as ‹#› to insert a comment at the end of a line
//This pretty much only happens directly after ‹)›, ‹]›, ‹}› when there is nothing on the same line after the cursor
‹print()3› –––> ‹print()#¦›
‹print() 3› –––> ‹print() #¦›
‹ print() 3› –––> ‹ print() #¦›
‹print()3comment› –––> ‹print()#comment¦›
‹[]3› –––> ‹[]#¦›
‹[x,y]3› –––> ‹[x,y]#¦›
‹x={}3› –––> ‹x={}#¦›
‹x={}3comment› –––> ‹x={}#comment¦›
‹x={} 3comment› –––> ‹x={} #comment¦›
EDGE CASES:
‹print([]3)› –/–> ‹print([]#)¦›
‹[3]› –/–> ‹[3#]¦›
5:
//When applicable, treat ‹5› as if it were ‹%›, or ‹55› as if it were ‹%%›
//This is used for iPython magics, which are always at the start of a line (ignoreing whitespace) and prefixed by % or %%
‹5magic› –––> ‹%magic¦›
‹55magic› –––> ‹%%magic¦›
‹ 5magic› –––> ‹ %magic¦›
EDGE CASES:
‹5m› –––> ‹%m¦›
‹5› –/–> ‹%¦›
‹55› –/–> ‹%%¦›
‹55m› –––> ‹%%m¦›
‹555magic› –/–> ‹%%%magic¦›
‹x5magic› –/–> ‹x%magic¦›
8:
//When calling or declaring arguments, or making elements in lists tuples or dict literals,
//‹8› can be used as the vararg ‹*› and ‹88› can be used as the kwarg ‹**›
FUNCTION DECLARATIONS:
‹def f(8args):› –––> ‹def f(*args):¦› //For function definitions
‹def f(88kwargs):› –––> ‹def f(**kwargs):¦›
‹def f(8args,88kwargs):› –––> ‹def f(*args,**kwargs):¦›
‹def f(8args,8kwargs):› –––> ‹def f(*args,**kwargs):¦› //TODO: Because we know that we can only have one *args in a function definition, the next * must be for kwargs, letting us save one keystroke
// (likewise, TODO: ‹def f(*args,*kwargs):› –––> ‹def f(*args,**kwargs):›)
FUNCTION CALLS:
‹print(8args)› –––> ‹print(*args)¦› //For function calls
‹print(88kwargs)› –––> ‹print(**kwargs)¦›
‹print(x,y,88kwargs)› –––> ‹print(x,y,**kwargs)¦›
‹f(8args):› –––> ‹f(*args¦)›
‹f(88kwargs):› –––> ‹f(**kwargs¦)›
EDGE CASES:
print(8) –/–> print(*)
‹f(8j):› –-–> ‹f(8j)› // TODO
‹f(8j):› –/–> ‹f(*j)› // TODO
‹f(8jj):› –-–> ‹f(*jj)› // TODO (Since 8j is a valid literal, it should activate the *'s on the next character that breaks syntax...)
SETS LISTS TUPLES:
‹[8x]› –––> ‹[*x]¦› //For data literals
‹{88x}› –––> ‹[**x]¦›
‹{8x}› –––> ‹[**x]¦› // TODO: Since we're in a dict literal, we know that a single * isn't an option; therefore it must be ** (saving one keystroke) (likewise, TODO: ‹{*x}› –––> ‹[**x]¦›)
‹(z,88x)› –––> ‹(z,**x)¦›
‹z,88x› –––> ‹(z,**x)¦›
EDGE CASES:
[x,8] –/–> [x,*]
[x,88] –/–> [x,**]
{8} –/–> {*}
[8j] –-–> [8j] // TODO
LAMBDAS:
‹lambda 8args:None› –––> ‹lambda *args:None¦› //For lambda declarations //TODO
‹lambda x,y,8args:None› –––> ‹lambda x,y,*args:None¦›
‹lambda 88kargs:None› –––> ‹lambda **kwargs:None¦›
9:
//If next character breaks syntax that () would fix, treat ‹9› as if it were originally ‹(›
//Note that normally ‹(› –––> ‹(¦)› from another completion, which is why we surround the cursor instead of simply inserting ‹(›
‹9hello› –––> ‹(hello¦)›
‹9x› –––> ‹(x¦)›
‹9jello› –––> ‹(jello¦)›
EDGE CASES:
‹9j› –––> ‹9j¦› //9j is a valid token...
‹9jj› –––> ‹(jj¦)› //...but 9jj is not
PSEUDO TERMINAL COMMANDS:
SUMMARY:
ALL COMMANDS:
<Input Modifier> <Namespace History> <Documentation> <Others> <File System>
MOD ON UNDO HELP RETURN (RET) RM
MOD OFF UNDO ON HHELP SUSPEND (SUS) RN
MOD SET UNDO OFF SHORTCUTS CLEAR MV
SMOD SET UNDO CLEAR WARN LS
UNDO ALL <Startup Files> GPU LST
<Stack Traces> RPRC TOP LSD
MORE <Prompt Toolkit> VIMRC TAB LSN
MMORE PT ON TMUXRC TABA CD
DMORE PT OFF XONSHRC VDA CDP
AMORE PT RYAN RPRC MONITOR CDA
GMORE RYAN VIMRC UPDATE CDB
HMORE <RP Settings> RYAN TMUXRC ANS PRINT ON (APON) CDU
RMORE PT SAVE RYAN XONSHRC ANS PRINT OFF (APOF) CDH
VIMORE PT RESET RYAN RANGERRC ANS PRINT FAST (APFA) CDH FAST
PIPMORE SET TITLE SHELL (SH) CDH GIT
IMPMORE SET STYLE <Inspection> LEVEL CDM
PREVMORE ? DITTO CDZ
NEXTMORE <Shell Commands> ?? EDIT CDQ
! ??? ?r VARS CAT
<Command History> !! ?. RANT NCAT
HISTORY (HIST) SRUNA ?v FORK CCAT
GHISTORY (GHIST) SSRUNA ?s ?lj WANS ACAT
AHISTORY (AHIST) ?t ?j WANS+ CATA
CHISTORY (CHIST) <Python> ?h (?/) ARG NCATA
DHISTORY (DHIST) PY ?e VIM CCATA
VHISTORY (VHIST) PYM ?p VIMH ACATA
ALLHISTORY (ALLHIST) APY ?c ?+c ?c+ ?cp VIMA PWD
APYM ?i AVIMA CPWD
<Clipboards> PU ?vd GC OFF APWD
COPY PIP GC ON TAKE
PASTE RUN GC MKDIR
EPASTE RUNA OPEN
WCOPY <Unimportant> OPENH
WPASTE <Simple Timer> NUM COM OPENA
TCOPY TICTOC PROF DEEP DISK
TPASTE TICTOC ON CDH CLEAN DISKH
LCOPY TICTOC OFF ALS TREE
LPASTE ALSD TREE ALL
VCOPY <Profiler> ALSF TREE DIR
VPASTE PROF TREE ALL DIR
FCOPY PROF ON FD
FPASTE PROF OFF AFD (FDA)
MLPASTE PROF FLAME FDT
PROF FLAME OPEN FDTA
<'ans' History> PROF FLAME COPY FD SEL (FDS)
NEXT PROF FLAME PASTE LS SEL (LSS)
PREV LS REL (LSR)
PREV ON <Toggle Colors> LS FZF (LSZ)
PREV OFF FANSI ON LS QUE (LSQ)
PREV CLEAR FANSI OFF RANGER (RNG)
PREV ALL
<Module Reloading>
RELOAD ON
RELOAD OFF
// NOTE: When a command here is listed like:
// SOME COMMAND (SMCMD)
// It means SMCMD is an alias for SOME COMMAND, and is therefore a shorthand equivalent.
//Also note that in SHORTCUTS, many of these command might have additional shorthands. They're listed here as well.
// Any of these commands can also be typed in lower-case without spaces, for shorthand
<Input Modifier>
// In pseudo-terminal, modifiers are preprocessors for your code.
// You can turn them on or off, or specify your own macro where | is the replacement
MODIFIER ON : Enables modifiers
MODIFIER OFF : Disables any modifier
MODIFIER SET : See https://asciinema.org/a/mb52gHyuFH92SXf32H6cuE4XR
SMODIFIER SET: See https://asciinema.org/a/7SVhDzt4yho4hggja9Muh5ffV
<Stack Traces>
MORE : Shows you a bigger stack trace. Always works.
Shortcut: m
MMORE : Shows you a more detailed stack trace with the values of every variable at every stack frame,
along with big chunks of code, but requires an external library. It's extremely useful for debugging.
Shortcut: mm
DMORE : Lauches a post-mortem debugger on the last error. If you have pudb, it will launch that debugger
instead of the defaut pdb library. It's useful when you want to get information that MMORE can't tell you.
Shortcut: dm
GMORE : Googles for your error in your default web browser
Shortcut: gm
AMORE : Stands for 'ans more'. Will set 'ans' to the latest error's exception, so you can perform custom tests on it.
Shortcut: am
HMORE : Almost exactly like MORE, except with syntax Highlighting
Shortcut: hm
VIMORE: Stands for 'vim more'. Used to edit the files you see in your stack trace with vim.
Shortcut: vm
PIPMORE: If you get an import error becuase a package isn't installed, simply use 'PIPMORE' to auto-install it
Shortcut: pm
IMPMORE: If you get an error like "NameError: name 'numpy' is not defined", this will automatically import numpy
Shortcut: im
PREVMORE: Goes to the previous error. It's kind of like the PREV command, but for errors.
Shortcut: um
NEXTMORE: The opposite of PREVMORE. It's kind of like the NEXT command, but for errors.
Shortcut: nm
<Command History>
HISTORY : Prints a list of all commands that you've entered that didn't cause errors. All green commands were single-liners,
and all yellow commands were multi-liners. Yellow commands alternate between bold and not-bold so you can visually distinguish
one multiline command from the next.
Shortcuts: hi, hist
GHISTORY: Prints a list of all single-line commands that didn't have errors. GHISTORY stands for 'green history', because in HISTORY all
single-liners are printed in green.
Shortcuts: gh, ghi, ghist
AHISTORY:
Sets ans to str(HISTORY)
Shortcuts: ah, ahi, ahist
CHISTORY: Stands for 'Copy History'. Copies the output of HISTORY to your clipboard.
Shortcuts: ch, chi, chist
DHISTORY: Stands for 'def History'. Extracts all function definitions from HISTORY and shows one of each to you
(it's easier than sifting through HISTORY manually to pull your functions out)
Shortcuts: dh, dhi, dhist
VHISTORY: Every time you close RP, your HISTORY is saved to a file. VHISTORY opens up that file in VIM. You can use it to select code and paste it back into RP.
Shortcuts: vh, vhi, vhist
ALLHISTORY: Shows all commands you entered, including the ones that caused errors. In a terminal, you can also press F3 to get a similar result.
<Clipboard>
COPY : Copies str(ans) to your clipboard. If you're using linux, please 'sudo apt install xclip'
Shortcut: co
PASTE: Sets ans to the string from your clipboard.
Shortcut: pa
EPASTE : Runs code from your clipboard. Stands for 'eval paste'
Pro tip: Equivalent to PASTE followed by RUNA (aka 'pa ra' using shortcuts)
Shortcuts: ep, epa
WCOPY : Attempts to serialize ans into a bytestring, then sends it to be copied online. It's counterpart is WPASTE.
Shortcuts: wc, wco
WPASTE: Pastes from a world-wide clipboard that's hosted on the internet. Any instance of rp that uses WCOPY can copy to this clipboard, letting
you copy and paste between computers easily. It supports many datatypes including numpy arrays, tensorflow tensors, lists, integers, floats and even lambdas and python
functions (including builtins) - as well as many other datatypes. Anything that the 'dill'
library supports is supported by WCOPY and WPASTE. The motivation behind this: Before, when writing code on things like the raspberry pi, it was annoying to bring code back
and fourth from my computer to the raspi. I had to use something
like email, etc, which meant leaving the terminal and using a GUI. But with this, you never even have to leave RP! Whatsmore, you can transfer more than just strings now :)
Shortcuts: wp, wpa
TCOPY: Copies str(ans) to your tmux clipboard. If there is no tmux running, this won't do anything.
Shortcuts: tc, tco
TPASTE: Pastes the tmux clipboard as ans. That way, you can copy something in tmux and paste it directly into rp as a string.
Pro tip: Follow TPASTE by COPY to copy your tmux clipboard to your system's clipboard, to paste tmux output into sublime or something.
Shortcuts: tp, tpa
VCOPY: Copies str(ans) into vim's clipboard. The next time you open vim, you can press 'p' to paste that string into vim.
Shortcuts: vc, vco
VPASTE: Paste's vim's clipboard contents into ans. Note that you have to yank something in vim, then exit vim, then this will work.
Pro tip: If this causes an error, run the command 'VCL' then try again. This stands for 'vim clear'. This will clear certain corrupted vim files, letting it work again.
Shortcuts: vp, vpa
FCOPY: Will let you select a file (or folder) and copy it over the web. It can be pasted at any computer using FPASTE
Shortcuts: fc, fco
$FCA: File-copies ans, assuming ans is a string that is the path to a file or folder
$FCH: File-copies current directory recursively
FPASTE: Assumes somebody recently used FCOPY somewhere in the world. It will paste the file (or folder) in your current directory.
Note: Behind the scenes, it uses WCOPY and WPASTE to do this. Large files, over a gigabyte, probably won't work well.
Shortcuts: fp, fpa
MLPASTE: When all else fails and we're in a nuclear apocalypse, this will still let you paste text into RP. Run this, then paste some content. When you're done, sent a KeyboardInterrupt by pressing Ctrl+C (or in Jupyter, by pressing 'stop')
Shortcut: mlp
<'ans' History>
// See https://asciinema.org/a/TFf9OvoRj1vmRqMPYDhHEyDsV
PREV : reverts ans to its previous value
Shortcut: pp
NEXT : The opposite of PREV. Undo is to PREV as redo is to NEXT.
Shortcut: n
PREV ON : Enables tracking ans's history. This is the default.
PREV OFF : Disables tracking ans's history. This can save memory.
PREV CLEAR: Deletes all ans history, which might save some memory. I rarely use it in practice.
PREV ALL : An alternative to typing PREV PREV PREV PREV PREV over and over again. This undoes ans as many times as it can.
<Namespace History>
//By default, undo-mode is turned off (aka UNDO OFF). This is to save memory.
UNDO : Reverts all visible variables to a previous state (TODO: show asciinema demo)
UNDO ON : When undo-mode is turned on, all variables are recorded each time you enter a command.
UNDO OFF: Opposite of UNDO ON
<Prompt Toolkit>
//TODO: Add video
PT: Toggles between PT ON and PT OFF
PT OFF: Disables prompt toolkit. This means using a simpler UI, with less features but also saving battery life.
PT ON : Enables prompt toolkit, letting you have things like autocompletions and multi-line editing etc.
<Saving Settings>
//TODO: Add video
PT SAVE : Prompt-Toolkit Save saves all the settings in the menu you get when pressing F2, as well as any title made by SET TITLE.
Shortcut: pts
PT RESET : Resets all the options in the F2 menu to their defaults.
SET TITLE: Lets you assign a title to this RP installation, displaying a tag on the bottom left.
Shortcut: st
SET STYLE: Lets you select a different prompt label (which is by default ' >>> ')
<Shell Commands>
//TODO: Add video
! : Like in jupyter notebook, using an exclamation mark before a shell command runs that shell command. For example, '!ls | grep .py' will list all
python files in your current directory
!!: Similar to the above single exclamation mark, having !! instead of ! will capture the standard output of your command to a string in 'ans',
instead of printing it to stdout. For example, '!!echo Hello World!' is the same as doing 'ans="Hello World!"'
Pro tip: If you need to use sudo, or interact with the command somehow, its best use a single exclamation mark. Otherwise, if you want to keep the output, use !!.
SRUNA : Equivalent to running "!*" where * is replaced by str(ans). Stands for 'Shell-Run Ans'
Shortcut: sa
SSRUNA: Equivalent to running "!!*" where * is replaced by str(ans)
Shortcut: ssa
<Simple Timer>
//TICTOC has nothing to do with TIKTOK - this came first - i promise lmao
//rp.tic() and rp.toc() are timing functions that work the same way they do in MATLAB
TICTOC: Toggles between TICTOC ON and TICTOC OFF
Shortcut: tt
TICTOC ON: When this is turned on, the time it takes to run each command will be displayed.
Pro tip: If the command runs super fast, try doing '\fo 100' to edit the command to run 100 times, or alternatively do 'DITTO 100' to run the previosuly-run command 100 times
TICTOC OFF: Turns that mode back off again.
<Profiler>
//TODO: Add video
PROF: Toggles PROF ON with PROF OFF. Quick and dirty. What I almost always end up using lol.
Shortcut: po
PROF ON: Will turn on the profiler for your next commands, telling you which function takes how long to run in a tree diagram next time you run a python command.
PROF OFF: Turns the profiler off.
<Toggle Colors>
FANSI ON: Enables terminal-based text coloring features of rp
Shortcut: fon
FANSI OFF: Disables terminal-based text coloring features of rp
Pro tip: This can be less laggy, especially on Windows terminals
Shortcuts: fof, foff
// This enables/disables rp.fansi() and rp.fansi_print()
<Module Reloading>
RELOAD ON: Will automatically reload modules that have changed since the previous prompt
RELOAD OFF: Disables that
<Documentation>
HELP: Lists commands
Shortcut: h
HHELP: Shows you this document
Shortcut: hh
SHORTCUTS: Shows you useful aliases
// Ones with a + at the end of the line are defined elsewhere in this help document, in some line starting with a $ sign
CLS aka CLEAR: Clears all terminal output. Equivalent to !clear
RS aka RESET: resets the current tty. Equivalent to !reset
RNA +