This question already has answers here:
Is there a decent Vim regexp OR command? What is the best way to find mismatched if else's?
(3 answers)
Closed 8 years ago.
Question is:
To display only lines contains keyword1 or keyword2,how to do that?
I know there's command like :g/pattern but that can work only for one keyword.
It's not duplicate question as it is to search instead of search replace case
Use alternation:
:g/foo\|bar\|baz/#
Related
This question already has answers here:
How to extract date from filename with extenstion using shell script
(2 answers)
Closed 9 months ago.
Here I print the file,
cat testfile.txt
demo_test_file_2022-06-06
i need a output like this
demo_test_file_ 2022-06-06
please help me for splitting the line when numbers present in Linux
thanks in advance
You need to read that file line-by-line into an std::string variable, then use find_first_of to find the first digit.
Then use substr
This question already has answers here:
How to get a substring after the last underscore (_) in unix shell script
(3 answers)
Closed 3 years ago.
I have a string like:
arn:aws:ecs:us-east-1:123456789:task-definition/myservice:10
Is there anyway I can get the last value 10? I tried to get last character but forgot that this int value can increase and eventually becomes 2 characters.
Well, many ways, this one works, though is not elegant :)
echo "arn:aws:ecs:us-east-1:123456789:task-definition/myservice:10" | sed 's/.*://'
This question already has answers here:
Customising word separators in vi
(6 answers)
Closed 7 years ago.
How can I customize word definition in Vim? The default is a series of character like _,[a-zA-Z] are considered as word. I'd like to add some other chars to this definition.
You can redefine the iskeyword setting.
Read the VIM docs for it or see this woss article for an example.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How do I join two lines in vi?
I have the following text:
the bunny
is very cute
How can I quickly delete the \n\t between bunny and is?
Type J (capital J) to join lines.
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Writing a vim function to insert a block of static text
How can i add multi line abbreviations in vi editor ?
I am using vi from ssh terminal.
if i type "head " the vi should replace "head" with 2 line sentence in the format
as shown below
MAINTENANCE HISTORY
DATE AUTHOR AND DETAILS
Thanks.
With vim you can do:
:iab head MAINTENANCE HISTORY<CR>DATE AUTHOR AND DETAILS
(Or use imap/inoremap instead of iab if you don't want to have to insert whitespace/punctuation before it activates)
No clue if this is possible in vi.