How to remove extra space after a colon in CSS using Sublime Text 2?

When autocomplete starts for the CSS style, Sublime by default adds a space after the colon:

position: relative; 

How to remove this space?

+6
source share
5 answers

I did some more digging and would like to suggest an alternative solution.

  • Open ~/Library/Application Support/Sublime Text 2/Packages/CSS/css_completions.py in Sublime.

  • On line 190, remove the space after the colon:

     l.append((p, p + ": ")) 

The only caveat I can think of is that it may be overwritten when upgrading Sublime, but it seemed to work fine without installing an additional package.

+15
source

Edit: I presented another solution below, but would like to leave it here if ppl is interested in Emmet, which still looks pretty neat.

I would suggest a slightly proven solution: P I got it to replace :<space> with :) .

This seems like a pretty popular plugin. I will scan the feature set first, because it looks like it will add a bunch of shortcuts that you might not want.

I think I could try / try this package myself. Hope this gives you what you are looking for.

Edit: I found that the instructions for the emmeter are somewhat vague. In particular, in Sublime Text 2 go to:

Sublime Text 2 > Preferences > Package Settings > Emmet > Settings - User and enter your override settings in JSON format. Conveniently, you can cut and paste the code template from Sublime Text 2 > Preferences > Package Settings > Emmet > Settings - Default (but leave this file alone as it will be overwritten when the package is updated).

+1
source

An additional answer is to add that if you are working in Sass or SCSS files, you will need to edit the fragments one at a time in ~ / Library / Application Support / Sublime Text 2 / Packages / Sass / Snippets to achieve this.

0
source

If you are using Emmet, the following solution should work with Sublime Text 3:

Open: Exalted Text 3> Package Setup> Emmett> Settings - User and Insert

 { "preferences": { "css.valueSeparator": ":", }, } 
0
source

Solution for sublime text 3:

Installing the Pacage control (if not already installed): Open ctrl + `

Insert:

 import urllib.request,os,hashlib; h = '2915d1851351e5ee549c20394736b442' + '8bc59f460fa1548d1514676163dafc88'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by) 

Press the eneter button, check the console, and restart the program.

Launch Pacage control using the combination Ctrl + Shift + P Select "Passive control: set Pacage", wait for a new window to appear. Select PackageResourceViewer Select "PackageResourceViewer: Open Resource" Select CSS Select css_completions.py

changes:

 .append ((p, p + ":")) 

on the

 .append ((p, p + ":")) 

If you have Emmet Pacage, you also need to do:

In the top menu, Package Setup> Emmett> Settings - User and Insert

 { "Preferences": { "Css.valueSeparator": ":" } } 
-9
source

All Articles