Skip to content

Instantly share code, notes, and snippets.

@junaidk
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save junaidk/ae92a9c0ba56cec9da1e to your computer and use it in GitHub Desktop.
Save junaidk/ae92a9c0ba56cec9da1e to your computer and use it in GitHub Desktop.
Plugin to remove line breaks and create a single line
import sublime, sublime_plugin
class LineCommand(sublime_plugin.TextCommand):
def run(self, edit):
s = self.view.sel()
for region in s:
if not region.empty():
selection = self.view.substr(region)
selection_mod = selection.replace('\n', ' ').replace('\r', '')
selection_mod = " ".join(selection_mod.split())
#self.view.insert(edit, 0, selection_mod)
sublime.set_clipboard(selection_mod)
sublime.status_message("Selection with removed 'New Line Chars' copied to clipboard")
#sublime.message_dialog("\"" + selection_mod +"\"" + "copied to clipboard")

###setup

  • create new sublime pulgin with above code and save it in packages/user/

  • in user key map add the following key binding

	{ 
		"keys": ["ctrl+alt+d"],
		"command": "line"
	}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment