How to match lines with only one tab in vim? - vim

I have a csv file. Some lines have 7 columns with tab delimited, and others have only one tab. I want to find all lines with only one tab and remove them.
What's the command to do this in VIM? I tried this but it doesn't work:
[^\t]+\t[^\t]+

Assuming you have a single tab or more on every line, this will remove all lines without multiple tabs.
:v/\t.*\t/d
If you have lines with no tabs that you want to retain, this will not work as it will remove them.

Related

mouse select copy from "vim" and "less" show different results

Case1: Open file1 in vi. Select a few lines(select copy is enabled). Paste in a different place.
Case 2: run the command less file1. From the console, select some lines. Paste in a different place.
In case2, I see that there are new lines introduced at where the line display shifts to new line. So, if the terminal width is 80 characters and my line is 100 characters, then 20 characters will be shown in the new line. If I copy from vim, all 100 characters are copied without any line-break. However, if I copy from "less" command, line-break is introduced after 80th character.
This messes up things like path.
Does "less" introduce line-break dynamically for lines longer than the display width?
less is not designed to handle mouse events. So when you select text while running it, the selection will be handled by the terminal behind, which doesn't give any sense to lines, paragraphs and so on; the text buffer is copied as it is displayed, that's all.
On the opposite, if you use vim with the right configuration, mouse events will be detected and treated by vim itself : the terminal will gracefully let vim handle them, for convenience. Then the line layout will be restored correctly when copying lines of text.

Sublime text 3. How to edit multiple lines? [duplicate]

This question already has answers here:
Sublime Text 2 multiple line edit
(10 answers)
Closed 6 years ago.
I was using Notepad++ and now I want to use the same cool features in Sublime but I don't know how.
I want to edit multiple lines at the same time like this:
But I don't want to Ctrl+Click at each line for this. I want to click at first line and click at last line for one vertical line.
How I can do this?
First, select multiple lines (by dragging mouse, shift+arrow, etc.). Then, press:
CTRL+SHIFT+L
or on MAC: CMD+SHIFT+L (as per comments)
Alternatively you can select lines and go to SELECTION MENU >> SPLIT INTO LINES.
Now you can edit multiple lines, move cursors etc. for all selected lines.
Use CTRL+D at each line and it will find the matching words and select them then you can use multiple cursors.
You can also use find to find all the occurrences and then it would be multiple cursors too.
Thank you for all answers!
I found it! It calls "Column selection (for Sublime)" and "Column Mode Editing (for Notepad++)"
https://www.sublimetext.com/docs/3/column_selection.html

Get ranges of edited lines in vim buffer

I use vim-codefmt and want it to only format the lines which were changed on save. Is there a way to grab a list of the lines which were changed?

Remove lines that doesn't contains a string with Sumlimes

I have 6 huge text files, and i need to filter them by deleting all the lines that doesn't contains the string: 53=S.
For 5 of them, i managed to filter the files with notepad++ as follow:
Find --> Mark --> Bookmark Lines --> Mark All --> Search --> Bookmarks -- > Remove Unbookmarked Lines
However, the application collapsed for a specific file each time i tried it. I tried it in two PCs with the same result.
Anyone know how can i remove the irrelevant lines with Sublimes or any other tool?
You could try a regular expression replace in notepad++.
Using notepad++, press ctrl+h or bring up the search>replace window.
In the 'find what' text box enter ^(?m)^(?:(?!53=S).)*$
and leave the 'replace with' text box empty
Make sure the search mode is set to 'Regular Expression' and then hit 'Replace All'
This should remove any line that doesn'tcontain the string 53=S
There is a notepad++ plugin called LineFilter (not LineFilter2), which provides a menu with entries like
delete all lines containing the selection
delete all lines not containig the selection
it opens a new tab with the result. That worked on large files. I liked it a lot.
The plugin is available from Notepad++ Plugin Central.
If you have grep available, then grep should do the trick, too.

Remove non utf8 lines in text file

How do i remove only non utf8 keywords/lines in a text file.
eg.
你好
相手123abc
this is only abc
I only want to remove lines that contain all english words and not the lines with utf8 words. So in this case only 'this is only abc' will be removed. Is it possible to do it in notepad++ or do i need to write a script for it?
This is possible using the following steps;
Open Notepad++ select the Find menu and select the last tab 'Mark', enter the regex ^(([a-zA-Z])+\s?)+, select Bookmark Line, and click the button 'Mark All'.
From the drop down menu select; Search --> Bookmark --> Remove Bookmarked Lines
I would also recommend making sure Notepad++ is up to date. I tested this with version 6.3. Marking lines is something added quite recently.

Resources