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

learn more… | top users | synonyms

10
votes
3answers
500 views

How do I modify the ci command in vim

Just like "ci(" changes everything between parentheses, I want "ci$" to change everything between dollar signs (for editing LaTeX.) Is this possible?
10
votes
2answers
367 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 ...
0
votes
1answer
64 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 ...
-1
votes
1answer
31 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
28 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 ...
0
votes
1answer
13 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 ...
3
votes
2answers
696 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 ...
1
vote
1answer
34 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 ...
13
votes
1answer
17k 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 ...
0
votes
1answer
30 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 ...
125
votes
4answers
108k views

Delete from cursor to end of line on VI

I know I've probably looked over this a million times in all the VI documents I've read, but I can't seem to find the delete from cursor to end of line command.
1
vote
4answers
53 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
28 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
81 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 ...
18
votes
3answers
8k views

How to automatically strip trailing spaces on save in Vi and Vim?

Is there a .vimrc setting to automatically remove trailing whitespace when saving a file? Ideally (to be safe) I would like to only have this functionality for certain files, e.g. *.rb
10
votes
3answers
3k views

Pasting from clipboard to vi-enabled zsh or bash shell

I'd like to be able to paste from the system clipboard (or text selection) into my "vi-like" shell prompt using the keyboard. I normally use zsh and sometimes bash. In both cases, I have the shell set ...
26
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 ...
3
votes
2answers
960 views

How to cancel :X encryption in vi

This has annoyed me for years but I've never found a solution. Instead of pressing Esc then :x to save an exit from vi, I accidentally type a capital X and press Enter. The only way to continue is to ...
1
vote
4answers
7k views

What is a vi equivalent of vim's 'set ruler' command?

Is there a way to show the current row and column position in vi? In vim, I know there is the set ruler command, but what are my options when using vi?
2
votes
1answer
906 views

Use of ! in VIM

I have seen that sometimes :q works but sometimes we have to use :q!. This is the case for many commands. I was wondering what is the general use of ! in vim and when to use it. I tried to google ...
2
votes
4answers
93 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 ...
0
votes
4answers
93 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 ...
3
votes
2answers
203 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 ...
3
votes
1answer
78 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 ...
0
votes
3answers
65 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 ...
12
votes
1answer
785 views

How to put current line at top/center/bottom of screen in vim?

Any quicker navigation trick to place the line at which the cursor is at the moment to the top of the screen? center of the screen? bottom of the screen?
3
votes
1answer
49 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
198 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 ...
5
votes
3answers
623 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
729 views

How to make vi work in single-user-mode?

When booting FreeBSD (I use 8.4-amd64) in single-user mode, mounting root filesystem in read/write mode and trying to vi some text file, I get all of this file's contents in one line. This makes vi ...
1
vote
1answer
35 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
124 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
64 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
42 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 ...
23
votes
5answers
5k views

Change cursor shape (or color) to indicate vi mode in bash

To clarify: I am not asking how to change the cursor when using vim within a terminal. I want the cursor to change when switching between input and command mode within Bash's vi-mode: set -o vi ...
2
votes
1answer
130 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 ...
2
votes
2answers
343 views

Pressing $ then Enter adds a newline before the last character, not after

I'm trying to add another line at the end of the last line in the VI editor and I need to go to the very last of the last line (command $) to insert a new line by hitting the enter key. But the cursor ...
1
vote
1answer
40 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
54 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
60 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
78 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 ...
3
votes
2answers
825 views

While in vi how can I pull in / insert / paste the contents of another file

I am editing file 'A' in vi. I have another file 'B' whose contents I want to 'paste' into my current location. Other than actual mouse copy and pasting, is there a command that I can use that will ...
0
votes
2answers
71 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
78 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 ...
26
votes
6answers
26k views

How to pipe the result of a grep search into a new vi file

I'm using grep -e Peugeot -e PeuGeot carlist.txt to search through carlist.txt and pull out some items and I presumed that grep -e Peugeot -e PeuGeot carlist.txt | vi would pipe it through for me but ...
1
vote
1answer
83 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 ...
49
votes
7answers
61k views

Vi vs vim, or, is there any reason why I would ever want to use vi?

I know a bit about *NIX text editors (currently migrating from nano to vim), and, after looking around a bit on the Unix & Linux SE, have noticed that vi is used instead of 'vim' in a fair number ...