vi is a screen-oriented text editor originally created for the Unix operating system.

learn more… | top users | synonyms

0
votes
4answers
62 views

How to add hostname as first line of a file

I have a file which has a few lines. one two three four five I need to add hostname of the server I'm working on as the first line of the file. For example if abcd555.india.com is the server, the ...
-6
votes
0answers
33 views

Write a Shell Script to generate a report named “Report_DDMMYYYY_HHMMSS.log” [closed]

Write a Shell Script to generate a report named "DD_MM_YYYY_HH_MM_SS.log"which performs the following operations: 1) ** Display the number of files present in the given directory (Directory name ...
0
votes
1answer
33 views

How do I delete the repeating word in vi editor?

I want to delete certain word in multiple locations ( say I want to delete the word " involve" form Vi editor and it appear 10000 times) from a vi editor?
0
votes
2answers
48 views

How to fetch all the even lines and odd lines from a file and save them into two different files such as Evenfile & Oddfile? [duplicate]

The question is very simple. Suppose I've a file named "a.txt" and it has 100 lines. Now I want to extract odd lines i.e lines 1,3,5...etc and save them to a different file such as Odd.txt and the ...
1
vote
1answer
128 views

Why does ci" (change inside quotes) not work in bash with vi mode enabled?

My favourite way to use bash is with readline's vi mode, enabled with set -o vi. It works perfectly for me, except that ci" does nothing. The change inside X feature does not work. What can I do to ...
52
votes
10answers
4k views

Use of touch and vi?

Is there a benefit of creating a file with touch prior to edit.. like: touch foo vi foo versus getting it to editor straight-away? Like: vi foo I see quite a few tutorials using the former (...
1
vote
3answers
42 views

how to make a large command line broke in two lines be executed as a single line inside of a script

I am very begginer with Unix. I am using IBM z/OS390 and I am using the OMVS shell. I don't have "vi" installed at all so I use "oedit". If I try to initialize the app.jar straigh from OMVS shell it ...
0
votes
1answer
27 views

How to delete part of a file and save it in another - using vi

Say you have a file call stuff.txt and you're editing it in vi. cat stuff.txt 11233 blah doesn't matter what <---------------------pretend your cursor is here xxcvbbb dfdfdd How can you ...
13
votes
2answers
456 views

What is “<Esc>Kv” in bash

When I am in bash and press Esc, Shift+K, V, bash fires up $EDITOR with a filename similar to /tmp/bash-fc-186566385. Why is that and what is its purpose? I probably need to mention that I am ...
-2
votes
1answer
36 views

How to replace all dots in vi

How to replace in vi? There are numerous explanations in Internet, but most of them doesn't contain information about which buttons to press. If I enter :s/[.]/[.] <ENTER> then only one ...
3
votes
2answers
30 views

How to replace a line with a certain pattern in vi?

I am trying to replace lines that contain the pattern "s#_decoded_block[" with "s#_decoded_block_". The command I am using to do that is %s/s\d\+_decoded_block\[/s\d\+_decoded_block_/g I expect to ...
3
votes
2answers
709 views

In vi/vim, how do I append to a file instead of overwriting it?

I know I can write to a file by simply doing :w <file>. I would like to know though how can I write to a file by appending to it instead of overwriting it. Example use case: I want to take some ...
0
votes
1answer
19 views

Less quit behavior

I'm not sure how to describe this but I'll try by comparing it to vi. When I open vi, do something, and then exit vi it brings me back to the terminal where I can see all of the commands I had ...
1
vote
1answer
48 views

Two different versions of VIM

When I install just about any distribution of linux it's accompanied with an unorthodox version of vi. I most recently dealt with this on Ubuntu 14.04. I can vi a file but a number of the "hot" keys ...
0
votes
1answer
71 views

How can I get rid of the byte-order mark 

I have created an html webpage when I run it at the bottom of the page there's some unwanted characters uncoding . I tried to get rid of it through vi using set nobomb but it still appears in the ...
1
vote
4answers
61 views

Command line in vi mode: replace all

How do I replace globally from the command line in vi mode. It seems like I can't use ex commands by prefixing with :, so what do I do instead. for instance if I want to replace all \ with / in a ...
0
votes
1answer
35 views

vi is frozen after search on arch linux

I'm on Arch Linux live USB. I'm using vi to open an 18kb text file containing a single line of json. I did a search with / and hit a block partway through the file represented by an @ symbol. Then, ...
0
votes
2answers
136 views

Linux server terminal - rows of tildes, can't write commands?

I'm pretty new - came across this problem. My webserver terminal is looking weird, there are some code echoes and then rows and rows of tilde. Where I type would be at the green square, but nothing I ...
27
votes
4answers
2k views

Does vi silently add a newline (LF) at the end of file?

I have trouble understanding a weird behavior: vi seems to add a newline (ASCII: LF, as it is a Unix (AIX) system) at the end of the file, when I did NOT specifically type it. I edit the file as such ...
2
votes
4answers
115 views

How to move to the “Nth” offset in a file

I'm in need of a command that would help me to the the N th offset in a file. Say this is my file's contents: [root@localhost ~]# cat /file1.txt this is the the first line of many lines and is just a ...
3
votes
2answers
206 views

How to write contents of a file to new file removing repeated lines [duplicate]

For example, a file file1.txt contains Hi how are you hello today is monday hello I am fine Hi how are you After the processing of file1.txt it should write to file2.txt and contents ...
0
votes
4answers
210 views

grep all the lines in a file and write line to a file from the pattern matching point

For example, a temp.txt file contains information like below: adsf on line jhkjhvjdbvjvbvbdjkvn qerwtt on line fdgdgdgdd qwqertg on line safffasffaf wrt on line adaddsd I want to grep for ...
0
votes
3answers
82 views

strange vi behavior on OSX Debian ssh terminal

While creating a swapfile I issue vi /etc/fstab as root. fstab file comes up, great. Issue G $ to jump to end of line and i to enter INSERT mode. Press the right arrow to move the cursor over by one ...
3
votes
1answer
57 views

Vim - Is there a way to get immediate visual feedback during Insert in Visual Block Mode?

I often press: <Ctrl> V to go into visual block mode and highlight a column hit <shift>-i (to insert at the beginning of the line), type a few things (at this point, I see my changes on ...
1
vote
3answers
205 views

How to match two lines at once in vim

I have a file that contains records with tab separated format but in two lines, I want to arrange records in one line with tab separated values using vim editor pattern match. Ex. Abc PQR ...
3
votes
2answers
28 views

vi — replace chars from part of line

I've got a file with all Belgian cities. Some of these cities have boroughs. Lier;stad;Antwerpen;49,70;33930;Lier;Koningshooikt Knokke-Heist;gem.;WestVlaanderen;56,44;33825;Knokke;Westkapelle;Heist;...
5
votes
3answers
630 views

When using vi typing a “c” will delete a character

This also happens when copying and pasting. I am attempting to edit Go code and typing or copying and pasting "package main" comes out as "pkage main". No idea why I can't type a c. Pressing delete ...
1
vote
1answer
36 views

With crtl-p can I open a file outside the current tree?

In looking to have functionality that can match my textmate friends for opening files with quick regex capability I found ctrl-p - https://github.com/ctrlpvim/ctrlp.vim It builds, indexes and then ...
1
vote
1answer
46 views

vi needs two <enter> keystrokes instead of one

If I want to open a file using "vi", it needs two <enter> keystrokes instead of one. Any idea, how to fix it? Just few hours back it was working perfectly. I have been searching on the net ...
1
vote
2answers
131 views

Not able to schedule tasks in crontab

[srinkann@sjc-ads-440 ~]$ crontab -e no crontab for srinkann - using an empty one /bin/sh: /usr/bin/vi: No such file or directory crontab: "/usr/bin/vi" exited with status 127 [srinkann@sjc-ads-440 ~]$...
0
votes
2answers
17 views

using matches of regex in vi global substitution

I am trying to edit a text file using vi where I want to replace the matches of [a-z],[A-Z] with: {matching value of [a-z]}{a space instead of a comma}{matching value of [A-Z]}. For example: ...
2
votes
1answer
68 views

VIM with Python - Multiple # do not get colored as a comment

Something changed on my system and now VIM screws up syntax highlighting of commented lines. This makes having 'debug' lines very difficult as it looks like the line is still active based on the ...
0
votes
2answers
62 views

Need help copying text from a webpage into vi?

I have this wall of text open on my browser that I need to copy and paste into vi in order to edit it. I tried controlC and controlV and it didn't work. I tried looking online, but everyone said to ...
2
votes
1answer
173 views

`crontab -e: E212: Can't open file for writing` when using gvim (works with vi)

As a user, I want to edit my crontab. crontab -e gvim is launched. It prints "/tmp/crontab.IUVYhK/crontab" [New DIRECTORY] I can write but as soon as I try to write the temporary file, I get ...
0
votes
1answer
59 views

Vi on Xenix: why instead of scroll the line overwrite the current line?

On linux and old Unix (at&t for example) when I scroll the line I see the text on Xenix the current read line is "overwriting" the screen. Look at video,you understand what i'm talking about How ...
1
vote
2answers
61 views

Cursor position in vi at opening of the file

vishex () { echo '#!/bin/bash' > $1; chmod +x $1; vi $1 } The goal of the above function is to have an alias for fast and comfortable creation of bash scripts. I would like that at ...
0
votes
1answer
84 views

How do I clean up vi and reinstall it completely? [closed]

Basically when I try to run vi, I have the following error (and after open it, there are a lot of errors): Error detected while processing function UltiSnips#bootstrap#Bootstrap: line 35: Traceback ...
0
votes
2answers
111 views

how to move the first line to the end of the file?

How to delete the line AFTER the first line that contains the patter:invHn3ion? and how to move the first line to the end of the file? anywhere i can learn all those expressions? My professor teaches ...
1
vote
1answer
93 views

Why is vi (but not cat) showing ^[[31m[^[[m^[[31m" after I use sed and output to a file I then edit? [closed]

When I use cat Variables/user-extensions.js | sed -e 's/css/XXX/' on an input file of the form storedVars["css_body"] = "css=body"; storedVars["css_main"] = "css=main"; I see output such as ...
0
votes
1answer
124 views

In vi, convert invisible characters into escape sequences?

My text in vim looks like, i am one line i come in next line i come after a tab space Can the above text be converted like this, i am one line\ni come in next line\n\ti come after a tab space
0
votes
0answers
41 views

readline emacs equivalent to vi's 'fc'

In vi readline, I can use the command fc where c is a character I want to find and jump to in the current line. E.g. echo 'hello world' fw --------> Is there an equivalent command in emacs mode? ...
1
vote
1answer
93 views

ex/vi: Input encoding conversion not supported

I've a problem with vi, every time I launched it I get this message: Input encoding conversion not supported; /tmp/vi.PSzqmm9ox9: new file: line 1. Despite of this message I'm able to edit and save ...
3
votes
1answer
99 views

EX editor: go to previous file

Using ex I open 3 files ex file1 file2 file3 I know the command :n goes to file 2 and file3 the command :rew go to file1 from file3 or file2 But what command can I use to go to previous file? I ...
6
votes
1answer
101 views

Start vi at the last line

I often find myself editing one of a set of configuration files by adding lines at the end. For editing I use vi (from bash) and currently use: vi +$(wc -c /home/john/master/tried.cfg) The above ...
1
vote
1answer
41 views

search and increase the values between the second tilde symbol and the 3rd tilde symbol in each line of a txt file

I was wondering is there any way to search and increase the values between the 2nd tilde symbol and the 3rd tilde symbol in each line of a txt file. Maybe vi can do this? For example, i have a test....
1
vote
1answer
32 views

How to search for <td>n in vim?

I can search for n with /n/ I can search for <td> with /\<td\>/ But how can I search for <td>n ? When I try /\<td\>n/ i get not found I'm trying to target the <td&...
0
votes
0answers
24 views

On OSX, vi seems to return 1 unexpectedly despite no error

So, on stock Mac OSX Yosemite, if I run vi /tmp/foo and then type in some text, and finally do :Wq (a common typo I make) and then :wq. Everything will appear to be fine, but for some reason the exit ...
2
votes
1answer
43 views

Vi mode or emacs mode in the whole system

I use vi mode in zsh, tmux and my favorite text editor (vim obviously). I'm interested to have this behavior in the whole system. I know I can use plugins in firefox, thunderbird, etc. but if there is ...
1
vote
1answer
42 views

Backward and forward search are reversed with vi mode in zsh

When I enter in vi mode with set -o vi, I enter in command mode, and I touch the key ? it produces a / and the reverse. Is it normal? How can I change this behavior?
0
votes
1answer
68 views

Faster way to enter in command mode with vi mode in the shell

I want to use the vi mode in bash but I find the ESC key a little bit too far, as for vim. The ideal can be to keep a key pressed, like ALT or the caps lock, to stay in command mode and be in insert ...