GithubHelp home page GithubHelp logo

vimsplain's Introduction

Vimsplain takes an sequence of vim commands and attempts to explain the meaning of the commands. Note that there are some Unicode-related problems with Python 2 so it's better to use a Python 3.x interpreter (usually installed as python3 or python3.1).

Usage:
python vimsplain.py commands

e.g.
> python vimsplain.py qa3jYpJDq2@aZZ
qa      record typed characters into named register {0-9a-zA-Z"} (uppercase to append)
3j      cursor 3 lines downward
Y       yank 1 lines [into buffer x]; synonym for "yy"
p       put the text [from register x] after the cursor 1 times
J       Join 2 lines; default is 2
D       delete the characters under the cursor until the end of the line and 1-1 more lines [into buffer x]; synonym for "d$"
q       (while recording) stops recording
2@a     execute the contents of register {a-z} 2 times
ZZ      store current file if modified, and exit

Normally escape sequences are noted by "^", e.g. "^C","^[". This introduces potential ambiguity, e.g. it is not possible to know wheter
^V
means 
^	cursor to the first CHAR of the line
V	start linewise Visual mode
or:
^V	start blockwise Visual mode.

Therefore, the non-standard approch of using '§' is used, since that character is not used as a command in Vim, and is easy to type on most keyboards. A drawback is that § can not be entered in Insert mode since it will be interpreted as CTRL.
Escape, or CTRL-[, is denoted by §[.
If the program is invoked with the --convert_special switch, <C-x> (where x is some character) will be converted to §x and <CR> will be converted to §M in the input. The reason this is only enabled when the switch is used is that it makes it impossible to enter some Vim commands (since these would be interpreted as a special character instead of commands).

A more compex example:
> python vimsplain.py "4JD=Gjwci(*a§[jcfda.join(',')§[ZZ"
4J      Join 4 lines; default is 2
D       delete the characters under the cursor until the end of the line and 1-1 more lines [into buffer x]; synonym for "d$"
=G      filter 1 lines through "indent" with motion cursor to line 1, default last line
j       cursor 1 lines downward
w       cursor 1 words forward
ci(     delete 1 text [into buffer x] and start insert with motion "inner block" from "[(" to "])"
                Text: *a
                Command: §[     end insert mode (unless 'insertmode' set)
j       cursor 1 lines downward
cfd     delete 1 text [into buffer x] and start insert with motion cursor to 1 occurrence of d to the right
                Text: a.join(',')
                Command: §[     end insert mode (unless 'insertmode' set)
ZZ      store current file if modified, and exit

There are still many features missing, most importantly support for arrow keys, mouse buttons, backspace and command line editing mode.

The file index.txt is a slightly modified version of the same file as included in Vim 7.3. It is licensed under the Vim license, see LICENSE.vim. Eveything else is licensed under the ISC license, see LICENSE.

Support the developer if you like this software:
http://flattr.com/thing/109977/Vimsplain

vimsplain's People

Contributors

pafcu avatar

Stargazers

Geoff Harcourt avatar

Watchers

Seth Woodworth avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.