nicholasbuse / sublime_deleteblanklines Goto Github PK
View Code? Open in Web Editor NEWSublimeText Plugin that deletes blank (or surplus blank) lines from a selection
SublimeText Plugin that deletes blank (or surplus blank) lines from a selection
Hey - So I love this plugin, but I can never remember the Commands off the top of my head, and it's really interruptive to go google them or open up the readme file via Sublime.
It would be great if there was Command Palette or Tool Menu (preferably both) entry for these
I'd be willing to work on the feature if you'd like.
I changed something, and works well. You can take it in your code, if you like.
def strip( self, edit, currentSelection, surplus ):
# Convert the input range to a string, this represents the original selection.
tokens = {'windows' : '\r\n',
'mac' : '\r',
'unix' : '\n',
}
line_endings = self.view.settings().get('default_line_ending')
rtnl = tokens.get(line_endings, '\n')
original = self.view.substr( currentSelection )
lines = filter(None, map(lambda s: s.rstrip(), original.split(rtnl))) # strip the trailing spaces
#lines = filter(lambda s: s.strip(), original.split(rtnl)) # do not strip the trailing spaces
if surplus: rtnl *= 2
output = rtnl.join(lines)
self.view.replace( edit, currentSelection, output )
return sublime.Region( currentSelection.begin(), currentSelection.begin() + len(output) )
No approximate combination of the defined keys works.
fn-ctrl-option-delete
ctrl-option-delete
cmd-option-delete
Any other suggestions?
It also doesn't show up under the preferences->package settings.
The following shotcut does not work on windows:
Ctrl+Alt+Shift+Backspace --> Delete Surplus Blank Lines
Hint: Deleting blank linkes works.
Using Win 10, and shortcut ctrl+alt+shift+backspace now adds carriage returns to each and every line.
I've uninstalled the plugin to ensure that the shortcuts were not mapped to anything else and also checked my keybindings but nothing there to suggest there's anything wrong.
Thanks.
DeleteBlankLines is not listed for install anymore.
It appears as MISSING in the package browser page: https://packagecontrol.io/packages/DeleteBlankLines
Windows, Sublime Text 3, Build 3143
Any chance to implement a setting that deletes the surplus blank lines on file save?
To get the actual line endings of a view you must use view.line_endings()
But doesn't the buffer of ST2 always has a line ending of \n whatever the specified line endings ?
Line endings is only used when writing the physical file.
I'm pretty sure you can remove all OS check and only keep the \n processing, but I didn't test.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.