Question: Use python 3.6... please be aware that there are more components to this excercise that aren't answered in the one previously answered. the one answered
Use python 3.6...
please be aware that there are more components to this excercise that aren't answered in the one previously answered. the one answered by chegg has only 10 commands. this one has 15....
Write (and test) the following 15 functions (names are taken from old vi editor) for each implementation. you will have to implement:
(1) cmd_h: move cursor one character to the left
(2) cmd_I: move cursor one character to the right
(3) cmd_j: move cursor vertically one line up
(4) cmd_k: move cursor vertically one line down
(5) cmd_X: delete the character to the left of the cursor
(6) cmd_D: remove on current line from cursor to the end
(7) cmd_dd: delete current line and move cursor to the beginning of next line (if next line exists, else do nothing)
(8) cmd_ddp: transpose two adjacent lines
(9) cmd_n: search for next occurrence of a string (assume that string to be searched is fully in one line.
(10) cmd_wq: write your representation as text file and save it
(11) cmd_r: search backwards for next occurrence of a string (from cursor till the beginning of the file). As for cmd_n, assume that string to be searched is fully in one line
(12) cmd_t: transpose two characters (one before and one after the cursor). If at the beginning of a file, do nothing
(13) cmd_plus: go to the beginning of next line (do nothing if you are on the last line)
(14) cmd_insert: insert a string at the cursor
(15) cms_sub: substitute replace the character at the cursor with another one for testing,
you will read the following nerdy poem (from the Zen of Python) into your file representation.
Beautiful is better than ugly.
Explicit is better than implicit. Simple is better than complex.
Complex is better than complicated.
After each command, print the contents of your file with character ^ as cursor. Example: your initial configuration is
^Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
After executing cmd_n(better), your representation should print:
Beautiful is ^better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
