prompt-toolkit / pyvim Goto Github PK
View Code? Open in Web Editor NEWPure Python Vim clone.
License: BSD 3-Clause "New" or "Revised" License
Pure Python Vim clone.
License: BSD 3-Clause "New" or "Revised" License
You know the joke about vim being so popular because it's impossible to quit..?
If I start pyvim without any arguments and open a file with :e some-file
, then if I try to quit vim with :q
, I see the message "1 more files to edit", and nothing else happens. I have to use :q!
or :qa
to quit.
Instead, if I start pyvim like pyvim some-file
, then :q
works fine.
Keep up the good work!
When I hit q!
, it closes all the open tabs and panes.
add two required pkgs: jsonschema, mistune, when pip install, the two pkgs aren't installed automatically
The link where you pointed to rope-like text parsing is from this editor:
https://github.com/martanne/vis
It has all the features in that long mail you linked to in another issue and is written in pure modern C.
Using Python 3.4 on Windows 10 TP.
Installed pyvim with pypy -m pip install pyvim
, launching with C:\PyPy3\bin\pyvim.exe, getting this error:
Fatal error in launcher: Job information querying failed
Using PyPy3 2.4.0 (32 bit).
I've noticed that ":q" causes (even on not changed file) to say "1 more file to edit" and editor will not close. ZZ does nothing, it should be equivalent to ":q".
Also ":bd" should close a split window (":q" should too).
When I open pyvim/commands/commands.py and goto line 357 (@cmd) it says pep warning (same way my vim does) but the code is not highlighted. The message is only displayed when you have cursor over the code. This seems strange.
When you have selected block visually, you can just press (c,d, ...) and the action should work. This works for visual select + c (as in change) but for deleting, you need to press d twice. This is incorrect.
I press 5gg, pyvim not work, just gg
and G
work as wanted
README.rst says "A Vi clone in Python" but other text hint at it being a vim clone. Is this a vi or vim clone? I guess it's a typo in the README
Is it possible to include terminal emulator support to prevent the need of a multiplexer?
Named buffers are not working: shortcuts "3y - yank selected into buffer number 3 .. instead of numbers it can contain also letters "ay (yank buffer a). You paste this with "3p or "ap.
*v_y*
{Visual}["x]y Yank the highlighted text [into register x] (for
{Visual} see |Visual-mode|). {not in Vi}
*v_Y*
{Visual}["x]Y Yank the highlighted lines [into register x] (for
{Visual} see |Visual-mode|). {not in Vi}
In vim when you open another buffer, it has current buffer number + 1. Now in pyvim it has buffer 0. Try openning one file, it gets buffer id 0. Open another file, and that now has also buffer id 0, but the previous opened file has buffer id 1. It should be indexed from buffer 1 up. First file gets buffer 1, another file gets buffer 2 .. etc. ..
Installing went fine, this however occurs when trying to run pyvim:
Traceback (most recent call last):
File "/usr/bin/pyvim", line 9, in <module>
load_entry_point('pyvim==0.0.4', 'console_scripts', 'pyvim')()
File "/usr/lib/python3.4/site-packages/pyvim-0.0.4-py3.4.egg/pyvim/entry_points/run_pyvim.py", line 34, in run
File "/usr/lib/python3.4/site-packages/pyvim-0.0.4-py3.4.egg/pyvim/editor.py", line 92, in __init__
File "/usr/lib/python3.4/site-packages/pyvim-0.0.4-py3.4.egg/pyvim/editor.py", line 177, in _create_application
TypeError: __init__() got an unexpected keyword argument 'get_style'
Am I missing something?
I'm using vim for my programming at work and NerdTree is big part of this. Without it it feels like being without hand.
This is a feature request for something similar.
In vim, when you press viw it select visual inside word and selects entire word. Now in pyvim it only selects from current cursor position.
Also vi) or vi( visual inside () is not working.
Visual around also is not working. va( va) vaw ... visual around () or visual around word.
I'm not exactly sure how the pyflakes works with files, but I'm missing the ability to see pep8 warnings and other in small horizontal split below the open file. This is extremely handy feature.
4.2 Substitute *:substitute*
*:s* *:su*
:[range]s[ubstitute]/{pattern}/{string}/[flags] [count]
For each line in [range] replace a match of {pattern}
with {string}.
For the {pattern} see |pattern|.
{string} can be a literal string, or something
special; see |sub-replace-special|.
When [range] and [count] are omitted, replace in the
current line only.
When [count] is given, replace in [count] lines,
starting with the last line in [range]. When [range]
is omitted start in the current line.
Also see |cmdline-ranges|.
See |:s_flags| for [flags].
This is functionality for search and replace %s/search/replace/g
*:s_flags*
The flags that you can use for the substitute commands:
[&] Must be the first one: Keep the flags from the previous substitute
command. Examples: >
:&&
:s/this/that/&
< Note that `:s` and `:&` don't keep the flags.
{not in Vi}
[c] Confirm each substitution. Vim highlights the matching string (with
|hl-IncSearch|). You can type: *:s_c*
'y' to substitute this match
'l' to substitute this match and then quit ("last")
'n' to skip this match
<Esc> to quit substituting
'a' to substitute this and all remaining matches {not in Vi}
'q' to quit substituting {not in Vi}
CTRL-E to scroll the screen up {not in Vi, not available when
compiled without the |+insert_expand| feature}
CTRL-Y to scroll the screen down {not in Vi, not available when
compiled without the |+insert_expand| feature}
If the 'edcompatible' option is on, Vim remembers the [c] flag and
toggles it each time you use it, but resets it when you give a new
search pattern.
{not in Vi: highlighting of the match, other responses than 'y' or 'n'}
[e] When the search pattern fails, do not issue an error message and, in
particular, continue in maps as if no error occurred. This is most
useful to prevent the "No match" error from breaking a mapping. Vim
does not suppress the following error messages, however:
Regular expressions can't be delimited by letters
\ should be followed by /, ? or &
No previous substitute regular expression
Trailing characters
Interrupted
{not in Vi}
[g] Replace all occurrences in the line. Without this argument,
replacement occurs only for the first occurrence in each line. If
the 'edcompatible' option is on, Vim remembers this flag and toggles
it each time you use it, but resets it when you give a new search
pattern. If the 'gdefault' option is on, this flag is on by default
and the [g] argument switches it off.
[i] Ignore case for the pattern. The 'ignorecase' and 'smartcase' options
are not used.
{not in Vi}
[I] Don't ignore case for the pattern. The 'ignorecase' and 'smartcase'
options are not used.
{not in Vi}
[n] Report the number of matches, do not actually substitute. The [c]
flag is ignored. The matches are reported as if 'report' is zero.
Useful to |count-items|.
If \= |sub-replace-expression| is used, the expression will be
evaluated in the |sandbox| at every match.
[p] Print the line containing the last substitute.
[#] Like [p] and prepend the line number.
[l] Like [p] but print the text like |:list|.
[r] Only useful in combination with `:&` or `:s` without arguments. `:&r`
works the same way as `:~`: When the search pattern is empty, use the
previously used search pattern instead of the search pattern from the
last substitute or `:global`. If the last command that did a search
was a substitute or `:global`, there is no effect. If the last
command was a search command such as "/", use the pattern from that
command.
For `:s` with an argument this already happens: >
:s/blue/red/
/green
:s//red/ or :~ or :&r
< The last commands will replace "green" with "red". >
:s/blue/red/
/green
:&
< The last command will replace "blue" with "red".
{not in Vi}
Note that there is no flag to change the "magicness" of the pattern. A
different command is used instead, or you can use |/\v| and friends. The
reason is that the flags can only be found by skipping the pattern, and in
order to skip the pattern the "magicness" must be known. Catch 22!
If the {pattern} for the substitute command is empty, the command uses the
pattern from the last substitute or `:global` command. If there is none, but
there is a previous search pattern, that one is used. With the [r] flag, the
command uses the pattern from the last substitute, `:global`, or search
command.
If the {string} is omitted the substitute is done as if it's empty. Thus the
matched pattern is deleted. The separator after {pattern} can also be left
out then. Example: >
:%s/TESTING
This deletes "TESTING" from all lines, but only one per line.
For compatibility with Vi these two exceptions are allowed:
"\/{string}/" and "\?{string}?" do the same as "//{string}/r".
"\&{string}&" does the same as "//{string}/".
*E146*
Instead of the '/' which surrounds the pattern and replacement string, you
can use any other single-byte character, but not an alphanumeric character,
'\', '"' or '|'. This is useful if you want to include a '/' in the search
pattern or replacement string. Example: >
:s+/+//+
For the definition of a pattern, see |pattern|. In Visual block mode, use
|/\%V| in the pattern to have the substitute work in the block only.
Otherwise it works on whole lines anyway.
*sub-replace-special* *:s\=*
When the {string} starts with "\=" it is evaluated as an expression, see
|sub-replace-expression|. You can use that for complex replacement or special
characters.
Otherwise these characters in {string} have a special meaning:
*:s%*
When {string} is equal to "%" and '/' is included with the 'cpoptions' option,
then the {string} of the previous substitute command is used, see |cpo-/|
magic nomagic action ~
& \& replaced with the whole matched pattern *s/\&*
\& & replaced with &
\0 replaced with the whole matched pattern *\0* *s/\0*
\1 replaced with the matched pattern in the first
pair of () *s/\1*
\2 replaced with the matched pattern in the second
pair of () *s/\2*
.. .. *s/\3*
\9 replaced with the matched pattern in the ninth
pair of () *s/\9*
~ \~ replaced with the {string} of the previous
substitute *s~*
\~ ~ replaced with ~ *s/\~*
\u next character made uppercase *s/\u*
\U following characters made uppercase, until \E *s/\U*
\l next character made lowercase *s/\l*
\L following characters made lowercase, until \E *s/\L*
\e end of \u, \U, \l and \L (NOTE: not <Esc>!) *s/\e*
\E end of \u, \U, \l and \L *s/\E*
<CR> split line in two at this point
(Type the <CR> as CTRL-V <Enter>) *s<CR>*
\r idem *s/\r*
\<CR> insert a carriage-return (CTRL-M)
(Type the <CR> as CTRL-V <Enter>) *s/\<CR>*
\n insert a <NL> (<NUL> in the file)
(does NOT break the line) *s/\n*
\b insert a <BS> *s/\b*
\t insert a <Tab> *s/\t*
\\ insert a single backslash *s/\\*
\x where x is any character not mentioned above:
Reserved for future expansion
The special meaning is also used inside the third argument {sub} of
the |substitute()| function with the following exceptions:
- A % inserts a percent literally without regard to 'cpoptions'.
- magic is always set without regard to 'magic'.
- A ~ inserts a tilde literally.
- <CR> and \r inserts a carriage-return (CTRL-M).
- \<CR> does not have a special meaning. it's just one of \x.
Examples: >
:s/a\|b/xxx\0xxx/g modifies "a b" to "xxxaxxx xxxbxxx"
:s/\([abc]\)\([efg]\)/\2\1/g modifies "af fa bg" to "fa fa gb"
:s/abcde/abc^Mde/ modifies "abcde" to "abc", "de" (two lines)
:s/$/\^M/ modifies "abcde" to "abcde^M"
:s/\w\+/\u\0/g modifies "bla bla" to "Bla Bla"
:s/\w\+/\L\u/g modifies "BLA bla" to "Bla Bla"
Note: "\L\u" can be used to capitalize the first letter of a word. This is
not compatible with Vi and older versions of Vim, where the "\u" would cancel
out the "\L". Same for "\U\l".
Note: In previous versions CTRL-V was handled in a special way. Since this is
not Vi compatible, this was removed. Use a backslash instead.
command text result ~
:s/aa/a^Ma/ aa a<line-break>a
:s/aa/a\^Ma/ aa a^Ma
:s/aa/a\\^Ma/ aa a\<line-break>a
(you need to type CTRL-V <CR> to get a ^M here)
The numbering of "\1", "\2" etc. is done based on which "\(" comes first in
the pattern (going left to right). When a parentheses group matches several
times, the last one will be used for "\1", "\2", etc. Example: >
:s/\(\(a[a-d] \)*\)/\2/ modifies "aa ab x" to "ab x"
When using parentheses in combination with '|', like in \([ab]\)\|\([cd]\),
either the first or second pattern in parentheses did not match, so either
\1 or \2 is empty. Example: >
:s/\([ab]\)\|\([cd]\)/\1x/g modifies "a b c d" to "ax bx x x"
<
Substitute with an expression *sub-replace-expression*
*sub-replace-\=* *s/\=*
When the substitute string starts with "\=" the remainder is interpreted as an
expression. This does not work recursively: a |substitute()| function inside
the expression cannot use "\=" for the substitute string.
The special meaning for characters as mentioned at |sub-replace-special| does
not apply except for "<CR>". A <NL> character is used as a line break, you
can get one with a double-quote string: "\n". Prepend a backslash to get a
real <NL> character (which will be a NUL in the file).
The "\=" notation can also be used inside the third argument {sub} of
|substitute()| function. In this case, the special meaning for characters as
mentioned at |sub-replace-special| does not apply at all. Especially, <CR> and
<NL> are interpreted not as a line break but as a carriage-return and a
new-line respectively.
When the result is a |List| then the items are joined with separating line
breaks. Thus each item becomes a line, except that they can contain line
breaks themselves.
The whole matched text can be accessed with "submatch(0)". The text matched
with the first pair of () with "submatch(1)". Likewise for further
sub-matches in ().
Be careful: The separation character must not appear in the expression!
Consider using a character like "@" or ":". There is no problem if the result
of the expression contains the separation character.
Examples: >
:s@\n@\="\r" . expand("$HOME") . "\r"@
This replaces an end-of-line with a new line containing the value of $HOME. >
s/E/\="\<Char-0x20ac>"/g
This replaces each 'E' character with a euro sign. Read more in |<Char->|.
File "/usr/local/bin/pyvim", line 11, in (60,1) - 25%
sys.exit(run())
File "/usr/local/lib/python2.7/site-packages/pyvim/entry_points/run_pyvim.py", line 48, in run
editor.run()
File "/usr/local/lib/python2.7/site-packages/pyvim/editor.py", line 288, in run
self.cli.read_input(reset_current_buffer=False)
File "/usr/local/lib/python2.7/site-packages/prompt_toolkit/interface.py", line 325, in read_input
self.renderer.reset()
File "/usr/local/lib/python2.7/site-packages/prompt_toolkit/renderer.py", line 211, in reset
self.output.flush()
File "/usr/local/lib/python2.7/site-packages/prompt_toolkit/terminal/vt100_output.py", line 166, in flush
self.stdout.write(data)
Interested in seeing the differences in the following projects? Is there any overlap and / or willing to collaborate? I'd like to avoid duplication / see sharing where possible.
https://github.com/kaaedit/kaa by @atsuoishimoto
https://github.com/stefanoborini/vai by @stefanoborini
Are there any other vi-like python text editors that fell under the radar?
pypy seems to be missing some built-in packages and will not run:
pypy pyvim/entry_points/run_pyvim.py
Traceback (most recent call last):
File "app_main.py", line 75, in run_toplevel
File "pyvim/entry_points/run_pyvim.py", line 14, in <module>
import docopt
ImportError: No module named docopt
I wanted to try pypy because python seems to be a bit laggy.
hello
i had install pyvim with no error, but when execute pyvim it can't running it says
ereo@orangestar:~/Software/pyvim$ pyvim
Traceback (most recent call last):
File "/usr/local/bin/pyvim", line 9, in
load_entry_point('pyvim==0.0.2', 'console_scripts', 'pyvim')()
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 521, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 2632, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 2312, in load
return self.resolve()
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 2318, in resolve
module = import(self.module_name, fromlist=['name'], level=0)
File "build/bdist.linux-x86_64/egg/pyvim/entry_points/run_pyvim.py", line 17, in
File "build/bdist.linux-x86_64/egg/pyvim/editor.py", line 27, in
File "build/bdist.linux-x86_64/egg/pyvim/layout.py", line 17, in
ImportError: No module named reactive
did i do something wrong? missing module?
regards
Im using vimdiff alot for config files comparison, this is really handy feature.
shortcuts:
]c - next diff
[c - previous diff
do - apply changes from other window to current window
du - apply changes from current window to other window.
In vim when you want mouse scrolling to scroll instead of just moving your cursor, you set in your .vimrc these:
set mouse=a
set ttymouse=xterm2
I tried to set these options in pyvim, but there are none. They should either be options, or enabled by default.
Traceback (most recent call last):
File "/Users/lillian/Documents/Projects/feeder/fbase/lib/python2.7/site-packages/pyvim/rc_file.py", line 52, in run_rc_file
namespace'configure'
File "/Users/lillian/.pyvimrc", line 33, in configure
self.display_unprintable_characters = True
NameError: global name 'self' is not defined
Press ENTER to continue...
pyvim installed in virtualenvvia pip on OS X 10.10.3 and python 2.7.6
.pyvimrc saved direct from site, no edits.
In vim you can use :b1 to go to buff number 1 .. with any number. This does not work in pyvim.
I'm not sure what is supposed to do, but when you apply it on line that has correct indent:
def _(attr):
it creates:
de f_(attr):
I'm not sure if this is desired behavior.
In Vim: Ctrl+v
This is vim's pymode rope function: goto function definition, shortcut g (control+c g)
When I create file with obvious syntax error, or bad import or other such thing, nothing happens. No errors, no warnings. Even after :w save still nothing. I installed pyflakes again with pip install pyflakes --upgrade, but I still have this issue. Any ideas?
I wrote a simple python Hello World program.
Then out of curiosity I just added about 200 empty lines after it. And then deleted them.
To my surprise now every time I try to write the print statement (that should appear in green color) the print keyword becomes invisible.
Even after restarting PyVim and my system, it does not revert to the original.
Note:
In the screenshot given below, the first line has been highlighted in visual mode and the second line has the cursor on the letter 'p'.
This may be a minor color bug or it may be a specific case of a more general issue. Will try to research on its effects.
PS: I am a student and a novice to OSS. Kindly please tell me if I do something wrong to help me learn. :)
Vim has shortcut for switching between vertical and horizontal splits:
ctrl+h/l or ctrl+left/right
ctrl+j/k or ctrl+up/down
These seem to be missing.
I suggest py.test instead of unittest for testing. I've been using pytest for large project for about half a year now and it is much better. And there is still time to switch with only one test :)
in pyvim there is :e and :edit, but vim uses :o and :open for these as well.
The screenshot in README for Chinese input displays weird Chinese characters, at least it's not Simplified Chinese nor Traditional Chinese. It might send a misleading signal to Chinese developers that pyvim display Chinese characters in gibberish.
I suggest using following text (Simplified Chinese) in the screenshot:
pyvim 是 Vi 的 Python 克隆版。目前本项目正处于开发阶段,但已基本可用。如果你有任何的疑惑或者发现了任何 bug,请通过 GitHub Issues 反馈。
Which means:
pyvim is a Vi clone in Python. It's under development but it's certainly usable. If you have any questions or find any bug, please feedback in GitHub Issues.
I was trying to add some shortcuts, but I was wondering where are most shortcuts for pyvim. I found them all in python-prompt-toolkit, why is that? You want to provide vim-like shortcuts to all who use prompt-toolkit?
I'm using ctrlp plugin, it basically scans the file and directory structure and provides smart file completion - file search. Sublime editor has similar feature. This is also super handy feature.
I have some vim plugin for this functionality - when you select some code and use < and > to move its indent, it stays selected. This is awesome feature and should be by default (in vim).
When :e on some directory, you should be able to press enter and that should open given file in another buffer.
pyvim requires bout 20mb without a file loaded, opening a 200kb CSV file takes about 60Mb of additional memory, and opening a 20Mb file more than 4Gb...
On Mac OS X using iTerm2
Ctrl-u causes half page-up as expected, whereas ctrl-d causes deletion of the character under the cursor instead of page-down as expected
after installation we need to type pyvim to run it, which is fine.
please pyvim be also made a executable module , such that we can run it using
python -m pyvim
It will be useful when there are multiple installation of python on the system - such as python3.3 ,python3.4 ,python 3.5 , and i want to install it in particular python and launch it from there as:
mypip3.4 install pyvim #this is already do-able,obviously
mypython3.4 -m pyvim #this needs t be supported
Aside from pep8 screaming of redefining of the same function name all the time, wouldn't there be upside to naming those functions for debugging purposes? Now when you'd print COMMANDS_TO_HANDLERS dict, you'd only get {'shortcut': <function _ 0x...>} and there is no telling them apart. While now this is OK, you can find the function by the @cmd decorator, when there is a ton of shortcuts, it'd be much better to have those functions with name.
If you agree, I'll send pull request with renaming.
When you :split or :vsplit the same file and scroll in one of them, both splits get scrolled. This should not happen.
I don't know if these controls are not supposed to work but as 'zz' works it seems incomplete to leave out 'zt' and 'zb'. Does this work for you? Is it actually a bug?
I'm having a hard time getting pyvim to do basic things such as allow me to type in the document. Hitting insert sill sometimes go to -- INSERT -- and hitting it again will not take me to --REPLACE --. Also I'm not able to leave the PyVim help, :q replies "No write since last change (add ! to override) but :q! replies "2 more files to edit".
Is the application just not ready for normal use yet? The screenshots look so good :/
Mistune module is missing from pip installer and the pyvim crashes after opening a file.
Not getting Jedi completion in Python source files. Tried enabling it with ':set jedi' at the Vim command prompt and also using the example file. Installed pyvim in a virtualenv under Python 2.7.9 on Debian. The jedi module did get installed by pip and imports OK in a Python prompt.
All else works great. Must be doing something wrong ...
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.