It will be nice to see, if the code in a Swift script is colored, highlighted and intended according to the language constructs.
In Apple’s Swift repository
( https://github.com/apple/swift/tree/master/utils/vim ), there exists a vim plugin, which will help us to display language constructs in more easily readable format by applying syntax highlighting, if the script is opened in
vim text editor.
In this article, we will see how to setup this plugin for an Ubuntu Linux system.
At first we will setup the
pathogen vim plugin which facilitates to setup other vim plugins very easily. In the second part, we we will set up the Apple’s vim plugin for Swift script for code highlighting and text indentation.
Part 1. Setup
Pathogen is vim text editor plugin, which makes it super easy to install other vim plugins. The project’s Github repository is available here.
1. Execute the given below commands
$mkdir -p ~/.vim/autoload ~/.vim/bundle $curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
2. Add the given below lines to
execute pathogen#infect() syntax on filetype plugin indent on
Part 2 . Setup Apple’s vim plugin for Swift’s code highligting and indentation
1. Download the plugin from Github repository
2. Copy the downloaded directory
$cp -r vim ~/.vim/bundle
3. Test the code highlighting
Open a swift file in vim editor and see the language constructs are highlighted.