witekbobrowski / vim-swiftdocstring

πŸ“‘ Vim plugin for generating docstrings in Swift sources

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool



Version Contact

A simple vim/neovim plugin that provides Xcode-like docstring templates for Swift


  • πŸ“‘ Generate Swift docstrings for types, functions and properties
  • πŸŽ› Support for /// and /** ... */ delimiters
  • 🎨 Even more customizable output
  • πŸ”¨ Xcode-like style of docstrings
  • 🧠 Better context awarness than in Xcode
  • πŸ”₯ Fast parsing using regular expressions
  • πŸ‘Œ Zero dependency (100% vim-script)


Plug 'witekbobrowski/vim-swiftdocstring'
Plugin 'witekbobrowski/vim-swiftdocstring'
call dein#add('witekbobrowski/vim-swiftdocstring')


  • :SwiftDocstringCurrent

    Generates docstring for the context in the current line of the cursor

  • :SwiftDocstringTypes

    Generates docstrings for every type declaration in current buffer

  • :SwiftDocstringFunctions

    Generates docstrings for every function declaration in current buffer


For your own convenience add the following to your .vimrc

" Generate docstring for current context on 'Tab' + '/'
autocmd Filetype swift nnoremap <silent><tab>/ :SwiftDocstringCurrent<CR>

For customized behaviour, change values of these properties. Values presented below are the defaults.

" Use Multi-line delimiter '/** ... */' instead of single-line '///'
" Boolen value (0 or 1)
let g:swiftdocstring#use_multi_line_delimiter = 0
" Set indentation for dosctring between the text and delimiters
" Integer value (>=0)
let g:swiftdocstring#text_indentation_level = 1
" Use placeholders for some components of the docstring 
" Boolen value (0 or 1)
let g:swiftdocstring#use_placeholders = 1
" Placeholders to be used if setting above is set as true 
" Two element string array
let g:swiftdocstring#placeholder_template = ['<#', '#>']


Everything you need to know about the usage of this plugin is basically here in this readme. Feel free to dive into the codebase for more answers. Very basic documentation is available from inside of vim itself with :h command.

:help swiftdocstring


This plugin was made under the desire to have a powerful Swift development environment in vim. Although the plugin brings only a small feature ported from Xcode, I want to add at least one brick to the wall. This is as far as I can go at the moment with the amount of time it took to create this piece of code. I intend it to remain simple, yet useful. Contributions are welcomed.


To learn more about Swift docstrings read this awesome article at NSHipster: Swift Documentation

Swift Documentation

Written by Nate Cook & Mattt β€” July 11th, 2018 (revised)


The plugin in licensed under MIT license so do what ever you want with it.


πŸ“‘ Vim plugin for generating docstrings in Swift sources

License:MIT License


Language:Vim Script 100.0%