I would like to be able to write handy “short version” in configuration file. The obvious way to achieve it would be “on save filter” executed by vi/vim. The filter script would rewrite “short version” to “long version” expected by the app. Answer Assuming code is an ex command that does your filtering (which could be calling a vimscript function,
Tag: vi
Why can’t I sudo echo a line in /etc/?
I am on centos and I did sudo echo ‘testline’>>/etc/test/test it said -bash: /etc/test/test: Permission denied However, when I do sudo vi /etc/test/test and insert testline and do :wq it writes out fine, why is this happening? Answer You need to wrap the whole statement (including the redirect) into a group so the sudo extends around it. Note: that, too,
Replace every occurrence of the regular expression matching with a particular in VI editor?
suppose I have a text file as follows. I need to obtain that text file as follows by replacing every table owner name occurrences replace witha same name called “informix”. out put should be like in vi editor , :%s/”kevin”/”informix”/g I can replace them individually but I need to do all of them at once. Answer Explanation:
How to add a string to line 13 in my text file
I have a very large text file that is difficult to open in text editors. Lines 12 – 15 are: I would like to add: 3 196 to line 14 and then have a blank line between 3 196 and Atoms like it is currently. I tried: But it did not seem to change anything. Anyone know of how I
Move to the end or beginning of the current line in VI when in insert mode
I am not proficient with my knowledge of VI editor and find it troublesome to keep pressing the -> (Right Arrow) key to move to the end of the line While searching on google I found that exiting the insert mode and then pressing the $ key will move the cursor to the end of the line. It works fine,
vi command to copy certain lines to another file
I have a log file with thousands of lines. I want to copy certain logs ranging between two line numbers to another file so that I can share them within team. For example – I want to copy text from line number 1000 to line 1200 to another file say issueLog.log What is the shortest way to do this? Note:
find and replace a String in vi editor on linux?
i am trying to replace String with new String in Linux vi editor but getting following error. Answer I’d guess the reason you’re getting that error message is because you intend to replace the string on all lines, not just the current one. In order to search all lines, add a % to your command:
How to substitute text which has implicit meaning in vi
I have a C code in vi from which I want to replace the text “n” with something else. Use of %s:n:(anything else) isn’t working. Is there any way to bypass this? For example,a line in the code is: printf(“Hello worldn”); In vi, I need to replace “n” in the printf line with a full stop. Use of substitue command
How to find the callers and callee of a function in C code in vi/vim?
I want to know how can I easily click (or maybe use some easy shortcuts) on a function name and find all its callee or open where it has been defined. Most of the web manuals in web are really hard to follow or don’t happen to work out. Say I want to click on allocuvm and see where it