/vim-force.com

Vim plugin for force.com

Primary LanguageVim Script

Vim plugin for developing on force.com

salesforce.com / force.com plugin for Vim version 7.4 (with job & channel support) or later.

Update September 2016

Note 1:
Majority of plugin functions have been migrated to async jobs and channels added in vim not so long ago.
You may need to update to a very recent version of your vim flavour because some initial versions (e.g. MacVim) with job support had problems with properly handling this functionality.
As always - make sure that you use latest tooling-force.com.jar.

Note 2: Minimum MacVim version which is known to (almost) work is 7.4, Included patches: 1-1831.
Current versions of MacVim GUI (as well as GVim) suffer from this issue.
The problem only manifests itelf if your java & tooling-force.com.jar config is wrong. If in doubt - test your config with :ApexValidateJavaConfig

Note 3:
This version has not been fully tested on MS Windows yet.
If you want to try it out - make sure to use latest vim version.

Note 4:
If you have to use older vim version or want to continue using synchronous version of all commands then switch to legacy-vim-sync branch.

Update July 2015

If you do not get code coverage data when running :ApexTestWithCoverage using one of meta-* flags then you are most likely affected by a bug in Metadata API Summer'15.
Workaround 1: use :ApexTestWithCoverage with tooling-sync or tooling-async flag.
Workaround 2: fall back to tooling-force.com-0.3.3.3.jar. Note: you will lose some of newer functions.

Update March 2015

If you are getting Internal Server Error when trying to deploy/save list of files which contain both Aura bundle(s) and Apex Class/Page then you are most likely affected by what appears to be a bug in Spring'15. Current workaround is to deploy Apex Classes/Pages first (:ApexDeployOne or :ApexDeployOpen or :ApexDeployStaged) and then call :ApexDeploy or :ApexSave as usual.

Update Feb. 2014

'master' branch of vim-force.com is no longer based on Ant and force.com migration tool. This version requires config changes, see :help force.com-installation, :help g:apex_tooling_force_dot_com_path and :help force.com-config-example.
If you want to continue using Ant + ant-salesforce.jar then switch to ant-based branch.

DESCRIPTION

vim-force.com plugin is a bunch of .vim scripts that allow to develop on force.com platform using Vim.

It is designed for those who do not feel productive in Force.com IDE for Eclipse.

General vim-force.com overview - http://www.youtube.com/watch?v=x5zKA6V__co
:ApexRetrieve command demo - http://youtu.be/umO86ji2Iqw
:ApexStage command demo - http://youtu.be/zQg8LORh8uc
Apex Code completion demo - http://youtu.be/u-6JQNuWRdE

Other vim plugins recommended for use alongside vim-force.com plugin

FEATURES

  • Build/Save to SFDC

    • with error reporting
    • "Run test"
      • Execute unit tests in all modified files
      • Execute unit tests in a selected Class
      • Execute selected test method in a selected Class
      • Display code coverage after running test
  • Deploy from one Org to Another

  • Delete selected metadata from SFDC

  • Execute Anonymous

    • whole buffer or selected lines
  • Execute SOQL query

    • supports Partner and Tooling APIs
  • Persistent "Stage" for cherry-picking and re-using list of components to be deployed or deleted

  • Load/update metadata from SFDC

    • Retrieve All or Selected components of given metadata type.
      Support for metadata types that reside inside folders (e.g. Document, Dashboard or Report) is limited because requires querying data (in addition to metadata).
  • Create triggers/classes/pages

  • Refresh project from SFDC

  • Search

    • find word in classes/triggers
    • find word everywhere
    • find visual selection
  • Syntax highlighting

    • supports syntax highlighting of Apex Classes, Triggers, Pages, JS Resources
  • List candidates for auto-completion in Apex classes. Invoked using vim omni-completion: Ctrl-X,Ctrl-O

  • List candidates (field names, object types, relationships, etc) for auto-completion in SOQL expressions. Invoked using vim omni-completion: Ctrl-X,Ctrl-O

  • Most commands (where it makes sense) can be run against different orgs without leaving current project.
    e.g.
    :ApexQuery will run selected SOQL query against the Org configured for current project
    :ApexQuery <api> MyOtherOrg will run the same query against 'MyOtherOrg'.
    Org name supports auto completion.

  • Handling content of zipped .resource files

    • useful when working with rich UIs with lots of javascript and CSS files
  • Basic (really basic) Visualforce code completion

    • try following in .page file
      < Ctrl-X,Ctrl-U
      <apex: Ctrl-X,Ctrl-U
      <chatter Ctrl-X,Ctrl-U
  • Initial support for aura/lightning

    • insert/delete/update/query for all aura file types is fully supported but there is currently no file templates or wizard to create various types of aura files. Use standard vim/file-system tools to create relevant files/folders.

LIMITATIONS

Salesforce.com API does not (in most cases) report error line numbers in Visualforce pages, making it impossible to go-to actual problem line if compile/save fails due to a syntax error.

Apex/SOQL auto-completion is a work in progress and there are many cases when it may not work as expected.

Installation/System requirements

Before vim-force.com plugin can be used the following requirements must be met:

  1. Vim version 7.4 (with job & channel support) or later, with :set nocompatible

  2. Java JDK/JRE, Version 8 or greater

  3. Tooling-force.com
    download jar from 'releases' page

  4. the rest see in vim doc :help force.com-system-requirements or directly in force.com.txt.

RECOMMENDED-PLUGINS

There is a number of great Vim plugins which you may want to consider

  • Fugitive - git support
  • unite.vim or ctrl-p - quick file/buffer open
  • NERDTree - project/file-system browsing
  • Pathogen - manage individually installed plugins in ~/.vim/bundle
  • UltiSnip - implements some of TextMate's snippets features in Vim
  • TagBar - a source code browser plugin for Vim

##CREDITS

Author: Andrey Gavrikov

Credit must go out to Bram Moolenaar and all the Vim developers for making the world's best editor (IMHO). I also want to thank everyone who helped and gave me suggestions. I wouldn't want to leave anyone out so I won't list names.