Tagged Questions
0
votes
1answer
23 views
Comment the if statement and the matching endif keyword
In vim, I can find the matching if statement and prepend the appropriate comment symbol. (e.g. %s/.alarm./#\0/g), but then I am left with dangling endifs that I have to find manually. I could simplify ...
5
votes
2answers
78 views
exact match in regrex when using vim, man, or less
when using vim, man, or less, I want to do some exact match in regrex
for example, when using man, I want to check the argument '-c'
if I use
/'-c'
the matching could be -cim ...
4
votes
1answer
151 views
Match word containing characters beyond a-zA-Z
To match a word one can use
\v(\w+)
From the vim help :h \w:
\w word character: [0-9A-Za-z_]
This works exactly as described in the manual. However, I want to
match words that contain ...
3
votes
2answers
115 views
How to add a line in many files
I have many .html files and I need to add a meta tag after <head>'s start tag in each file.
How I can do that?
Can vim help me?
2
votes
3answers
191 views
How to reverse-match a string in the Vim programming language?
I want to find the last index of any character in the [abc] set in the abcabc string but the search should start from the end of the string:
" Returns the 0th index but I want the 5th.
let ...
4
votes
1answer
103 views
Using Regex in vim movment
Is there any way to use regular expression for movement in vim. For example,
I want to move my cursor to the first occurrence of the pattern abc. So can I do something analogous to fa but now a ...
5
votes
3answers
195 views
VIM see regular expressions matches as you type
If I type /regex then the cursor temporarily jumps to the first match and all matches are highlighted. This updates as I type. Is it possible to get this behavior when I'm getting ready to make a ...
0
votes
1answer
93 views
Replacement in VIM with regular expression matched part unchanged
Suppose I want to append two digit numbers in my file with "some_thing".
Like from this:
12 23 45
to
12_something 23_something 45_something
How can I do this using regular expression ...
1
vote
1answer
262 views
Multiply certain numbers in a text -file by certain constant
I want an alternative solution to this jQuery hack, tasting a bit reinventing the wheel -- look I am sure I could do this with some one-liner using basic *ix tools. Look much easier and ...
2
votes
1answer
791 views
Replace using VIM, reuse part of the search pattern
I am working with VIm and trying to set up a search and replace command to do some replacements where I can re-use the regular expression that is part of my search string.
A simple example would be a ...
2
votes
1answer
143 views
Expand regex on multiple lines in Vim
I am working on removing comments from a C source file. Let's focus on multiline comments
/* ... */ and ignore the inline ones (//)
The following command seems to work with (solaris) sed:
...
4
votes
3answers
157 views
vim regex not need \ to escape
In Vim is there an option to write regexs in the same style as Awk for example/sp\{0,\}/ Would be
/sp{0,}/
3
votes
3answers
163 views
What does . match?
In working with regular expressions, I have been told that a dot character . will match everything.
Except for newlines \n.
Are there any other exceptions? What about the NUL character \0, or the ...
6
votes
3answers
603 views
Replacing Multiple blank lines with a single blank line in vim / sed
Question more or less says it all. I'm aware that /^$/d will remove all blank lines, but I can't see how to say 'replace two or more blank lines with a single blank line'
Any ideas?
2
votes
2answers
363 views
lookbehind and using it with grep in Vi?
Trying to get into Vi (not Vim), after learning Vim.
Vim has a lookabehind like /\(Not this\)\@<!$, how to do it in Vi?
If I want to search recurvively down directory in Vim, I could do :vimgrep ...