Hi.
how to remove duplicate lines in selected text in which there may be extra spaces or tabs in the middle of the text, the text itself is identical.
. — space or tab
Text.text.text
Text…text…text
Hi.
how to remove duplicate lines in selected text in which there may be extra spaces or tabs in the middle of the text, the text itself is identical.
. — space or tab
Text.text.text
Text…text…text
I wrote this and put it as deleteSpacesFw.py
and bound it in Packages/UserDefault (OSX).sublime-keymap
with:
{ "keys": ["ctrl+alt+right"], "command": "delete_spaces_forward"}
:
import sublime, sublime_plugin
import re
class deleteSpacesForwardCommand(sublime_plugin.TextCommand):
def run(self, edit):
view = self.view
has_selection = len(view.sel()[0]) > 0
if not has_selection:
selreg = view.find(r'\s+', view.sel()[0].a, sublime.IGNORECASE)
sublime.status_message(f'spaces deleted: {len(selreg)}')
self.view.erase(edit, selreg)
Sorry, I read “empty lines”. For duplicated lines ignoring spaces, you should delete spaces and compare. Is a bit longer code
This is impossible because I can break the structure of the text. Sometimes these spaces are needed and if, for example, there are 100,000 lines, it will be impossible to notice it.
It is necessary to somehow do it in the background.
Or something like this to find:
Go to line has this option but its only go to 1 line at time.
Or: Maby there was plugin to
plugin to save selection,but they do this only on original file and restore selection on other file imposible.
Extras: Plugin
PowerCursors
But you don’t need to change the structure of the file. What I suggest is to compare the lines without spaces, no to change them. And if the lines without spaces are equal, delete in the original. I think it should be done with uniq
(ignoring spaces or the things you want to ignore) and that’s something quite specific
I will try to do so i think i understand your hack
I did not think of such a way out of the situation, thank you
SMART!!!
this is my problem))
in this line space betwen 519 and buttn neded.
tcimg=$cm519 buttn=TDlgCustomColors||TButton2|$
In that line there is additional two space near || and they are not important.
tcimg=$cm519 buttn=TDlgCustomColors || TButton2|$
in general they are all the same…