add basic "set" command, with "ft" and "tw" options
This commit is contained in:
parent
86101ef8ac
commit
5fe2f87c24
1 changed files with 22 additions and 0 deletions
|
|
@ -165,6 +165,28 @@ class Ex
|
|||
else
|
||||
pane.splitUp(copyActiveItem: true)
|
||||
|
||||
set: (args...) ->
|
||||
editor = ->
|
||||
atom.workspace.getActiveTextEditor()
|
||||
|
||||
arg = args[1]
|
||||
regex = /\s*(\w+)(?:\s*=\s*([\d\w]+)\s*|(!))/
|
||||
matches = arg.match regex
|
||||
return unless matches?
|
||||
|
||||
[whole, option, value, bang] = matches
|
||||
|
||||
switch option
|
||||
when 'tw'
|
||||
editor().setTabLength(parseInt(value))
|
||||
when 'ft'
|
||||
regex = new RegExp "(source|text)\.#{value}$"
|
||||
lowerCaseName = value.toLowerCase()
|
||||
for name, grammar of atom.grammars.grammarsByScopeName
|
||||
grammarName = grammar.name.toLowerCase()
|
||||
if name.match(regex) or lowerCaseName is grammarName
|
||||
editor().setGrammar(grammar)
|
||||
|
||||
sp: (args...) => @split(args...)
|
||||
|
||||
substitute: (range, args) ->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue