libvim.swift is a Swift package that provides a wrapper around libvim: the core Vim editing engine implemented as a minimal C library. Note that the current scope of this is limited to hiding away C types and pointer interaction; that is, the API itself is more or less identical to the C API provided by libvim (i.e., it is not "Swifty").
- Integration: Easily integrate Vim functionalities into your Swift applications.
- Customization: Customize Vim behaviors according to your application's needs.
- Efficiency: Leverage the powerful text editing capabilities of Vim within your Swift codebase.
You can install libvim.swift
using Swift Package Manager.
dependencies: [
.package(url: "https://github.com/kaii-zen/libvim.swift", from: "0.0.1")
]
import libvim
// Example usage
vimInit()
vimInput("i")
vimInput("H")
vimInput("e")
vimInput("l")
vimInput("l")
vimInput("o")
vimInput(",")
vimInput(" ")
vimInput("W")
vimInput("o")
vimInput("r")
vimInput("l")
vimInput("d")
vimInput("!")
vimKey("<esc>")
print(vimBufferGetLine(vimBufferGetCurrent, 1)) // -> Hello, World!
For more rudimentary examples have a look at the tests. For a basic UIKit example, see Example/.
- Swift 5.10+
- macOS 14+
- An Apple Silicon Mac
(there is probably no real reason for this, it's just the versions I started with)
Contributions to libvim.swift are welcomed and encouraged! To contribute:
- Fork the repository.
- Create your feature branch:
git checkout -b feature/new-feature
. - Commit your changes:
git commit -am 'Add new feature'
. - Push to the branch:
git push origin feature/new-feature
. - Submit a pull request.
libvim.swift is licensed under the MIT License.
- Bram Moolenaar for authoring and maintaining the iconic Vim text editor for over 30 years; up until his passing on August 3rd 2023.
- The onivim project for creating libvim: The core Vim editing engine as a minimal C library.
- Contributors to Swift Package Manager for enabling easy dependency management in Swift projects.