go to line in logfile with multitail - tail

Using mulitail, I want to find a specific line in the logs, so I press the / key and type the string i want to search for. multitail pops up a box with all the lines found in the logs, but now I want to 'go to' that location in the log file, so that I can see what happened before or after the specific line.
Is it possible?
Alternatively, is it possible to specify a number n to return +/- n lines above and below the found string rather than just the 1 line where the string was found?

Related

add or substract a number to each word of a line in Vim

I want a substract a positif number to each word of the current line. I know the Ctrl-X shortcut, but sadly it applies only to the first word if I use it in a visual selection
I found, a solution using a trick taken from here : reverse the order of words of a line in Vim exploding the current line into words, with the command 's/ +/\r/g`
for example, if I want to substract 3 to each word, i will register the following macro in the register w
qwOjok:s/ +/\r/g{jv}3v}Jkddq
That solution could be improved, because using the macro one multiple lines does not work. I tried to used a mark instead of { to jump, but it does not prevent to mix the lines

Is there a simple way to edit a numbered list using vim markdown?

Let's say I have a numbered list like this in markdown:
1. This is a line of text.
2. This is a line of text.
3. This is a line of text.
4. This is a line of text.
Is there an easy way to insert a new line for number one and add one to all the other lines using vim? This is what I want to achieve:
1. This is a new line of text.
2. This is a line of text.
3. This is a line of text.
4. This is a line of text.
5. This is a line of text.
I want to be able to do this quickly - not having to record a macro for instance.
A completely different approach would be not to worry about manually numbering at all. Markdown doesn't care what numbers are in your source file, so
1. Foo
1. Bar
1. Baz
Renders as
Foo
Bar
Baz
I normally number all of my ordered lists with 1. and let the Markdown processor take care of actual numbering.
There's a couple ways you could do this. Probably the simplest way is to add a newline starting with a '0.'. Then, when you are happy with this list you can increment every number with vG<C-a>. (Of course, it's not the whole buffer you could use a different movement such as ip or })
If you are going to add a line many times, it might be easier to add all of the numbers at the end when you are done editing. This could be done by visually selecting the lines you want and doing g<C-a>.
I don't remember exactly when these feature's were added, but this requires a relatively new version of vim. It works for me in 8, and I remember this working for 7.4 with the right patches.
If you are on an older version of vim, you could select the lines you want and use a substitute command to add the appropriate numbers. For example:
:s/^/\=(line('.') - line("'<") + 1).'. '
This: You can use the command below after selecting those lines by V4j starting from first line:
:'<,'>s/\d/\=submatch(0)+1/ | normal! goO1. This is a new line of text.
Or: Put the cursor on first line and type:
O0. This is a new line of text.Esc0Ctrl-v4jCtrl-a
O : letter o in capital case (shift+o)
0 : digit 0

How to complete the whole list with Vim?

I have a list of products to place on a rails seed and I would like to instead of put brackets one by one on the list with a command place the brackets on the whole list?
for example:
1. Dakine
2. Dale of Norway
3. Dan Post
1. ["Dakine"],
2. ["Dale of Norway"],
3. ["Dan Post"],
I searched on the help but did not find any about. Thanks.
You can record a macro in Vim and repeat that.
If you are on number 1, you can do following:
qqf a["Esc$a"],Esc0jq
Explanation:
qq: Start recording macro in register q
f: Go to first space character
a: : Insert after (the space character from above)
\[": Insert those characters
Esc: Back to normal mode
$: Go to end of line
a: Insert after (end of line)
"],: Insert the characters
Esc: Back to normal mode
0: Jump to start of line
j: Go down one line
If you have 100 such lines, you can do 100#q to achieve your result.
With vim substitute command:
:%s/.*/["&"]/
If you don't want to operate on all lines, then select the ones you want to transform or note the related line numbers, and then type :s/..... without the %. You'll see actually :'<,'>s this range represent the visually selected lines, and vim adds it automatically in visual mode.
On Atom you can enable the find to use Regex in the search(there is a button next to the search field)
Then you can search for something like (^.*$) to get every line separated by groups and in the Replace field you use ["$1"],. The $1 represents the value matched by the Regex.
Then just do a Replace All and remove the last comma in your list if needed.

Vim get correct behavior for `gq` command inside a python doc string

Suppose I have the following documentation line in a python script.
def cdf():
"""
Each line in the printed output will contain a fraction and a number, such that
the given fraction of all numbers in the log file have values less than or
equal to the given number.
"""
If I highlight the string contents and use the command gq, vim will make sure each line is only 80 characters long, but it will also tend to push the second and third line towards the left margin, which is undesirable. Is there a way to make gq reformat to ensure 80 character width without pushing the second two lines to the left?

vim: FuzzyFinder and the numbers of the list of the matching file names

I'm using FuzzyFinder, when I start to write the name of a file to open it, a list of files that match the letters are shown. On the left of each of those files there is a number.
What do those number mean? Is there maybe any way to open a file from the list using that number?
Or what way do you use for selecting the files from the list apart from using the cursor keys?
Javi
Those numbers can be used if you append it after a ; - so if you type ab and end up with a list with 10 files, you can select the 5th with ab;5.
You could also select a file from the list without entering a pattern at all, starting directly with ; and following with a number in the list. More info at :h fuf-search-patterns.
I use Ctrl-p/Ctrl-n to select the match, similar to cursor keys, when the desired file is at most three or four positions from the top.

Resources