sponsor Vim development Vim logo Vim Book Ad

angular.vim : Some niceties for the AngularJS framework

 script karma  Rating 12/5, Downloaded by 436  Comments, bugs, improvements  Vim wiki

created by
Kevin Burnett
script type

Switch to test file and vice versa


A, the "alternate" file, has been mapped to take you from your code to the corresponding test file, or from your test file to the corresponding implementation file. For example, if you're in app/js/rock-socks.js, and you hammer :A, you will be taken to test/spec/rock-socks.js, if such a file exists. Some other common directory structure conventions in the angular community, such as app/src and test/unit, are also supported. Feel free to file a pull request if your reasonable convention doesn't work.

Jump to definition of service/directive/controller/etc


"Go to file" has been slightly overriden to take you to the definition of the file under your cursor. If you're reading some code like this...

if (true) {
...and your cursor is on AwesomeService, and you hammer gf, if there is a file called awesome-service.js somewhere in a subdirectory of your path, you will be taken there. The default behavior of gf can also be quite useful in the context of an angular app, since html fragments are specified as file paths in views (with ng-include src="full/path.html), directives (with templateUrl: 'src/myapp/modules/main/views//prompt-list.html', so an attempt has been made to allow this to work as well. If all that is missing from a template path is the "app" directory (which is a common value for "cwd" in Gruntfile.js, the plugin will add this for you as well. If either of these two things don't work for your use case, file a ticket, figure out why and file a pull request, or use ctags.

Run the current spec

If you're writing jasmine unit tests for your angular app, they look like this:

it('should work', function() {
  var actualThing = 'cow';

Now, if you take that "it" prefix, and replace it with "iit", instead of running your entire suite, it will run JUST THAT ONE SPEC. There are probably bad reasons to want to do this, like if your build is broken and you only want to fix your code, but it can be pretty handy to focus in on just one spec at a time (and one spec generally runs way fast).

So, if you're anywhere inside a spec:


or the "run spec" mapping:


will toggle the spec between "it" and "iit." This works especially well if you have a karma watch going. See the screencast at http://notkeepingitreal.com (soon come).
install details
Extract in ~/.vim or ~\vimfiles.

Grab the very latest from http://github.com/burnettk/vim-angular
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
angular.zip 2.0.0 2015-04-22 7.0 Kevin Burnett Supports jasmine 2 conventions.
angular.zip 1.0.1 2014-04-07 7.0 Kevin Burnett lots of refactors, tests
angular.zip 1.0 2014-04-02 7.0 Kevin Burnett Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
OSDN.net Logo