https://github.com/tjdevries/plib.vim
Python standard library functions on vim objects
https://github.com/tjdevries/plib.vim
Last synced: 4 months ago
JSON representation
Python standard library functions on vim objects
- Host: GitHub
- URL: https://github.com/tjdevries/plib.vim
- Owner: tjdevries
- License: mit
- Created: 2017-07-05T21:56:50.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-07-05T22:07:36.000Z (almost 9 years ago)
- Last Synced: 2025-03-06T08:16:11.859Z (over 1 year ago)
- Language: Vim script
- Size: 3.91 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# plib.vim
Python 3 standard library functions on vim objects
To view documentation for the functions, see the [Python List Documentation](https://docs.python.org/3/tutorial/datastructures.html#more-on-lists).
## Usage
First install it and make sure it's in the runtimepath. I use vim-plug for that
```vim
call plug#begin()
Plug 'tjdevries/plib.vim'
call plug#end()
```
Then you can use it to do things with objects!
```vim
let List = plib#List()
" This is the example shown in the Python 3 documentation
let fruits = ['orange', 'apple', 'pear', 'banana', 'kiwi', 'apple', 'banana']
echo List.count(fruits, 'apple')
" 2
echo List.count(fruits, 'tangerine')
" 0
echo List.index(fruits, 'banana')
" 3
" Find next banana starting a position 4
echo List.index(fruits, 'banana', 4)
" 6
call List.reverse(fruits)
echo fruits
" ['banana', 'apple', 'kiwi', 'banana', 'pear', 'apple', 'orange']
call List.append(fruits, 'grape')
echo fruits
" ['banana', 'apple', 'kiwi', 'banana', 'pear', 'apple', 'orange', 'grape']
call List.sort(fruits)
echo fruits
" ['apple', 'apple', 'banana', 'banana', 'grape', 'kiwi', 'orange', 'pear']
echo List.pop(fruits)
" 'pear'
```