VimScript for Python developers

57 views
Skip to first unread message

Yegappan Lakshmanan

unread,
May 31, 2020, 11:20:09 PM5/31/20
to vim...@googlegroups.com
Hi all,

I have put together the following gist to help Python developers
with VimScript:


Let me know if you have any comments/suggestions.

Thanks,
Yegappan

Bram Moolenaar

unread,
Jun 1, 2020, 8:09:15 AM6/1/20
to vim...@googlegroups.com, Yegappan Lakshmanan

Yegappan wrote:

> I have put together the following gist to help Python developers
> with VimScript:
>
> https://gist.github.com/yegappan/16d964a37ead0979b05e655aa036cad0

Very useful!

> Let me know if you have any comments/suggestions.

Some things are identical. Instead of the reader staring at the text to
spot any differences, how about just saying "the same". E.g. at the
start of "Comparison Operators".

For dictionaries it would be useful to mention the #{} form:

let d = {'red' : 10, 'blue' : 20} or #{red : 10, blue : 20}
let x = {}

Some day it would be nice to do the same for Vim9 script.

--
"The amigos also appear to be guilty of not citing the work of others who had
gone before them. Even worse, they have a chapter about modeling time and
space without making a single reference to Star Trek!"
(Scott Ambler, reviewing the UML User Guide)

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Christian Brabandt

unread,
Jun 1, 2020, 12:32:05 PM6/1/20
to vim...@googlegroups.com
Very nice. Are you keeping this up to date there? Perhaps a link to this
reference should be included in the help

I notice this:

> Finding string length

The mentioned functions (len(), strlen()) do not handle multibyte
characters, but return the byte-length, perhaps explicitly add
strwidth()

> Getting a substring

Again, using str[index] uses byte index, same for strpart, perhaps
mention strcharpart()

> Checking whether a string starts with or ends with a substring

> if str =~# "^ing"

Please use single quotes, so that if one adds other regular expression
atoms such as \+ or \d one do not have to double the backslashes.


Best,
Christian
--
Ein Kompromiss, das ist die Kunst, einen Kuchen so zu teilen, daß
jeder meint, er habe das größte Stück bekommen.
-- Ludwig Erhard

Yegappan Lakshmanan

unread,
Jun 1, 2020, 12:56:39 PM6/1/20
to Bram Moolenaar, vim...@googlegroups.com
Hi Bram,

On Mon, Jun 1, 2020 at 5:09 AM Bram Moolenaar <Br...@moolenaar.net> wrote:

Yegappan wrote:

> I have put together the following gist to help Python developers
> with VimScript:
>
> https://gist.github.com/yegappan/16d964a37ead0979b05e655aa036cad0

Very useful!

> Let me know if you have any comments/suggestions.

Some things are identical.  Instead of the reader staring at the text to
spot any differences, how about just saying "the same".  E.g. at the
start of "Comparison Operators".

I have now used a table to compare the various operators.
 

For dictionaries it would be useful to mention the #{} form:

let d = {'red' : 10, 'blue' : 20}  or  #{red : 10, blue : 20}
let x = {}

I have updated the gist with this.
 

Some day it would be nice to do the same for Vim9 script.


Once the Vim9 script has all the features as Vim8, I will create
another gist.

Regards,
Yegappan

Yegappan Lakshmanan

unread,
Jun 1, 2020, 1:08:04 PM6/1/20
to vim...@googlegroups.com
Hi Christian,

On Mon, Jun 1, 2020 at 9:31 AM Christian Brabandt <cbl...@256bit.org> wrote:

On So, 31 Mai 2020, Yegappan Lakshmanan wrote:

> Hi all,
>
> I have put together the following gist to help Python developers
> with VimScript:
>
> https://gist.github.com/yegappan/16d964a37ead0979b05e655aa036cad0
>
> Let me know if you have any comments/suggestions.

Very nice. Are you keeping this up to date there? Perhaps a link to this
reference should be included in the help

Yes. I am planning to keep this up-to-date.
 

I notice this:

> Finding string length

The mentioned functions (len(), strlen()) do not handle multibyte
characters, but return the byte-length, perhaps explicitly add
strwidth()

> Getting a substring

Again, using str[index] uses byte index, same for strpart, perhaps
mention strcharpart()

> Checking whether a string starts with or ends with a substring

> if str =~# "^ing"

Please use single quotes, so that if one adds other regular expression
atoms such as \+ or \d one do not have to double the backslashes. 
 

Thanks for the review comments. I have updated the gist with these comments.

Regards,
Yegappan

Prabir Shrestha

unread,
Jun 13, 2020, 6:02:09 AM6/13/20
to vim_use
There is also Vim Script for JavaScripters. https://w0rp.com/blog/post/vim-script-for-the-javascripter/

Bram Moolenaar

unread,
Jun 13, 2020, 7:21:42 AM6/13/20
to vim...@googlegroups.com, Prabir Shrestha

Prabir Shrestha wrote:

> There is also Vim Script for JavaScripters.
> https://w0rp.com/blog/post/vim-script-for-the-javascripter/

Thanks, that also looks useful. I'll add the link to usr_41.txt.

--
CUSTOMER: You're not fooling anyone y'know. Look, isn't there something
you can do?
DEAD PERSON: I feel happy... I feel happy.
[whop]
CUSTOMER: Ah, thanks very much.
MORTICIAN: Not at all. See you on Thursday.
CUSTOMER: Right.
The Quest for the Holy Grail (Monty Python)

Yegappan Lakshmanan

unread,
Jun 13, 2020, 10:29:45 AM6/13/20
to vim...@googlegroups.com
Hi,

On Sat, Jun 13, 2020 at 3:02 AM Prabir Shrestha <ma...@prabir.me> wrote:
There is also Vim Script for JavaScripters. https://w0rp.com/blog/post/vim-script-for-the-javascripter/


Yes. This page is also mentioned in my gist.

BTW, I have added a lot of content to the gist recently. Review comments and
suggestions are welcome.


Regards,
Yegappan
Reply all
Reply to author
Forward
0 new messages