Skip to content

use $0 for last stop postion in snippets #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 23 additions & 22 deletions snippets/coffee/angular_coffee.snippets
Original file line number Diff line number Diff line change
Expand Up @@ -3,114 +3,115 @@
# You can change the controller name and parameters
snippet ngc
${1:controllerName} = (${2:scope}, ${3:injectables}) ->
${4}
${0}
# angular.foreach loop
snippet ngfor
angular.forEach ${1:iterateOver}, (value, key) ->
${2}
${0}
## Module Based Snippets
# A new angular module without a config function
snippet ngm
angular.module '${1:moduleName}', [${2:moduleDependencies}]
${3}
${0}
# A new angular module without a config function and a variable assignment
snippet ngma
${1:moduleName} = angular.module '$1', [${2:moduleDeps}]
${3}
${0}
# A new angular module with a config function
snippet ngmc
${1:moduleName} = angular.module('$1', [${2:moduleDeps}], (${3:configDeps}) ->
${4}
${0}
)
# A factory in a module
snippet ngmfa
factory '${1:factoryName}', (${2:dependencies}) ->
${3}
${0}
# Define an Angular Module Service to be attached to a previously defined module
# You can change the service name and service injectables
snippet ngms
service '${1:serviceName}', (${2:injectables}) ->
${3}
${0}
# Define an Angular Module Filter to be attached to a previously defined module
# You can change the filter name
snippet ngmfi
filter '${1:filterName}', (${2:injectables}) ->
(input, ${3:args}) ->
${4}
${0}
## Route Based Snippets
# Defines a when condition of an AngularJS route
snippet ngrw
$routeProvider.when '${1:url}',
templateUrl: '${2:templateUrl}'
controller: '${3:controller}'
${4}
${0}
# Defines a when condition of an AngularJS route with the resolve block
snippet ngrwr
$routeProvider.when '${1:url}',
templateUrl: '${2:templateUrl}'
controller: '${3:controller}'
resolve:
${4}
${5}
${0}
# Defines an otherwise condition of an AngularJS route
snippet ngro
$routeProvider.otherwise redirectTo: '${1:url}'
${2}
${0}
## Scope Related Snippets
# Define a new $scope'd function (usually inside an AngularJS Controller)
# You can change the function name and arguments
snippet $f
$scope.${1:functionName} = (${2:args}) ->
${3}
${0}
# Defines a new $scope'd variable inside an AngularJS controller
snippet $v
$scope.${1:variable} = ${2:value}
${3}
${0}
# Defines a new $scope'd variable inside an AngularJS controller and assigns a value from a constructor arguments
snippet $va
$scope.${1:variable} = ${2:variable}
${3}
${0}
# Define a $watch for an expression
# You can change the expression to be watched
snippet $w
$scope.$watch '${1:watchExpr}', (newValue, oldValue) ->
${2}
${0}
# Define a $on for a $broadcast/$emit on the $scope inside an Angular Controller
# You can change the event name to listen on
snippet $on
$scope.$on '${1:eventName}', (event, ${2:args}) ->
${3}
${0}
# Define a $broadcast for a $scope inside an Angular Controller / Angular Controller Function
# You can change the event name and optional event arguments
snippet $b
$scope.$broadcast '${1:eventName}', ${2:eventArgs}
${3}
${0}
# Define an $emit for a $scope inside an Angular Controller / Angular Controller Function
# You can change the event name and optional event arguments
snippet $e
$scope.$emit '${1:eventName}', ${2:eventArgs}
${3}
${0}
## Directive related snippets
# A compile function
snippet ngdcf
compile = (tElement, tAttrs, transclude) ->
(scope, element, attrs) ->
${1}
${0}
# A linking function in a directive
snippet ngdlf
(scope, element, attrs${1:ctrl}) ->
${2}
${0}
# A directive with a compile function
snippet ngdc
directive '${1:directiveName}', factory = (${2:injectables}) ->
directiveDefinitionObject =
${3:directiveAttrs}
compile: compile = (tElement, tAttrs, transclude) ->
(scope, element, attrs) ->
${0}
directiveDefinitionObject
# A directive with a linking function only
snippet ngdl
.directive('${1:directiveName}', (${2:directiveDeps}) ->
(scope, element, attrs${3:ctrl}) ->
${4}
)
${0}
)
14 changes: 7 additions & 7 deletions snippets/haml/angular_haml.snippets
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
snippet ngindex
%html
%head
%script{:src => "https://ajax.googleapis.com/ajax/libs/angularjs/${1:1.2.12}/angular.js"}
%script{:src => "https://ajax.googleapis.com/ajax/libs/angularjs/${1:1.6.3}/angular.js"}
%body{"ng-app" => true}
${2}
${0}
# Script tag importing base AngularJS file from CDN
snippet ngsa
%script{:src => "https://ajax.googleapis.com/ajax/libs/angularjs/${1:1.2.12}/angular.js"}
${2}
%script{:src => "https://ajax.googleapis.com/ajax/libs/angularjs/${1:1.6.3}/angular.js"}
${0}
# A script tag holding Angular's template
snippet ngst
%script{:type => "text/ng-template", :id => "${1:id}"}
${2}
${0}
# A binding in AngularJS
snippet ngb
{{${1:binding}}}${2}
{{${1:binding}}}
# Bind a view to a model
snippet ngm
ng-model="${1:model}"
# Disable a form element
snippet ngd
snippet ngd
ng-disabled="${1:model}"
14 changes: 7 additions & 7 deletions snippets/html/angular_html.snippets
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@
snippet ngindex
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/${1:1.2.12}/angular.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/${1:1.6.3}/angular.js"></script>
</head>
<body ng-app>

${2}
${0}

</body>
</html>
# Script tag importing base AngularJS file from CDN
snippet ngsa
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/${1:1.2.12}/angular.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/${1:1.6.3}/angular.js"></script>

${2}
${0}
# A script tag holding Angular's template
snippet ngst
<script type="text/ng-template" id="${1:id}">
${2}
${0}
</script>
# A binding in AngularJS
snippet ngb
{{${1:binding}}}${2}
{{${1:binding}}}
# Bind a view to a model
snippet ngm
ng-model="${1:model}"
# Disable a form element
snippet ngd
snippet ngd
ng-disabled="${1:model}"
# Conditionally render an element
snippet ngi
Expand Down
46 changes: 23 additions & 23 deletions snippets/javascript/angular_js.snippets
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,44 @@
# You can change the controller name and parameters
snippet ngc
var ${1:controllerName} = function(${2:scope}, ${3:injectables}) {
${4}
${0}
};
# angular.foreach loop
snippet ngfor
angular.forEach(${1:iterateOver}, function(value, key) {
${2}
${0}
});
## Module Based Snippets
# A new angular module without a config function
snippet ngm
angular.module('${1:moduleName}', [${2:moduleDependencies}]);
${3}
${0}
# A new angular module without a config function and a variable assignment
snippet ngma
var ${1:moduleName} = angular.module('$1', [${2:moduleDeps}]);
${3}
${0}
# A new angular module with a config function
snippet ngmc
var ${1:moduleName} = angular.module('$1', [${2:moduleDeps}], function(${3:configDeps}) {
${4}
${0}
});
# A factory in a module
snippet ngmfa
factory('${1:factoryName}', function(${2:dependencies}) {
${3}
${0}
});
# Define an Angular Module Service to be attached to a previously defined module
# You can change the service name and service injectables
snippet ngms
service('${1:serviceName}', function(${2:injectables}) {
${3}
${0}
});
# Define an Angular Module Filter to be attached to a previously defined module
# You can change the filter name
snippet ngmfi
filter('${1:filterName}', function(${2:injectables}) {
return function(input, ${3:args}) {
${4}
${0}
};
});
## Route Based Snippets
Expand All @@ -50,7 +50,7 @@ snippet ngrw
templateUrl: '${2:templateUrl}',
controller: '${3:controller}'
});
${4}
${0}
# Defines a when condition of an AngularJS route with the resolve block
snippet ngrwr
$routeProvider.when('${1:url}', {
Expand All @@ -60,62 +60,62 @@ snippet ngrwr
${4}
}
});
${5}
${0}
# Defines an otherwise condition of an AngularJS route
snippet ngro
$routeProvider.otherwise({
redirectTo: '${1:url}'
});
${2}
${0}
## Scope Related Snippets
# Define a new $scope'd function (usually inside an AngularJS Controller)
# You can change the function name and arguments
snippet $f
$scope.${1:functionName} = function(${2:args}) {
${3}
${0}
};
# Defines a new $scope'd variable inside an AngularJS controller
snippet $v
$scope.${1:variable} = ${2:value};
${3}
${0}
# Defines a new $scope'd variable inside an AngularJS controller and assigns a value from a constructor arguments
snippet $va
$scope.${1:variable} = ${2:variable};
${3}
${0}
# Define a $watch for an expression
# You can change the expression to be watched
snippet $w
$scope.$watch('${1:watchExpr}', function(newValue, oldValue) {
${2}
${0}
});
# Define a $on for a $broadcast/$emit on the $scope inside an Angular Controller
# You can change the event name to listen on
snippet $on
$scope.$on('${1:eventName}', function(event, ${2:args}) {
${3}
${0}
});
# Define a $broadcast for a $scope inside an Angular Controller / Angular Controller Function
# You can change the event name and optional event arguments
snippet $b
$scope.$broadcast('${1:eventName}', ${2:eventArgs});
${3}
${0}
# Define an $emit for a $scope inside an Angular Controller / Angular Controller Function
# You can change the event name and optional event arguments
snippet $e
$scope.$emit('${1:eventName}', ${2:eventArgs});
${3}
${0}
## Directive related snippets
# A compile function
snippet ngdcf
function compile(tElement, tAttrs, transclude) {
return function(scope, element, attrs) {
${1}
${0}
}
}
# A linking function in a directive
snippet ngdlf
function(scope, element, attrs${1:ctrl}) {
${2}
${0}
}
# A directive with a compile function
snippet ngdc
Expand All @@ -124,7 +124,7 @@ snippet ngdc
${3:directiveAttrs},
compile: function compile(tElement, tAttrs, transclude) {
return function (scope, element, attrs) {

${0}
}
}
};
Expand All @@ -134,6 +134,6 @@ snippet ngdc
snippet ngdl
.directive('${1:directiveName}', function(${2:directiveDeps}) {
return function(scope, element, attrs${3:ctrl}) {
${4}
${0}
}
});
});