vi is a screen-oriented text editor originally created for the Unix operating system.
23
votes
4answers
2k views
Why does `ESC` move the cursor back in vim?
In vim, when I hit ESC to return to command mode, the cursor moves one character to the left. This is not what I would hope for, occasional I immediately hit l to move back to that spot, perhaps to ...
20
votes
1answer
1k views
How to get root inside of vi? [duplicate]
Possible Duplicate:
Becoming root from inside Vim
It could happen to anyone. The admin types:
vi /etc/resolv.conf
as a regulare user. He edits the /etc/resolv.conf file, but when he ...
18
votes
9answers
1k views
Bash commands inside vi
Is it possible to type a bash command inside vi and get the stdout?
I find it often tedious to close and reopen vi just because I want to look something up in the shell.
18
votes
3answers
8k 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.
18
votes
3answers
1k 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 ...
17
votes
6answers
1k 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 a fair about of question use vi instead of ...
16
votes
6answers
1k views
Using VI to edit shell commands in UNIX
I used to have a co-worker who was really good at UNIX.
He showed me how to use Vi to edit my shell commands.
He placed the command in a file that ran every time I logged in.
Since then, I've ...
13
votes
2answers
2k views
What is the difference between vi and vim?
As far as I know vi is more commonly found on out-of-the-box unix systems while vim often has to be installed. Also vim stands for vi improved, but improved how?
What are the main differences?
9
votes
2answers
299 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?
8
votes
2answers
1k views
Can less invoke vim instead of the default vi when I hit the 'v' key?
I want to launch vim instead of the default vi editor when I hit v in less.
Are there any settings I can modify to allow me to do this?
8
votes
3answers
1k views
Advantages of using set -o vi
I have seen many developers using this command to set the option to vi. I never understood the real use of this?
When using bash commands, what help does switching to vi provide?
8
votes
4answers
375 views
How can I paste (overwriting) with vim?
In vim I use yy and p all the time to yank and paste lines. However, if I want to replace one line multiple places in the file, I can't use yy p dd p because the dd deletes the line to the clipboard ...
8
votes
2answers
303 views
Vim command for inserting a character
I'm looking for the opposite of x. I want to insert just one character and stay in command mode.
7
votes
2answers
165 views
How do I get just the user-manual for Vim
To get the vim user-manual I am doing
vi test
and then, once the file is opened, I do
:help user-manual
This opens up a split window, which makes reading manual inconvenient to read. How do I ...
7
votes
2answers
669 views
why inode value changes when we edit in “vi” editor?
When I edit a file in "vi" editor the inode value of the file is changing. But when edited with cat command the inode value is not changing.
7
votes
1answer
151 views
Vim: Making XML text “pretty”
Is there an easy way within vi to make your XML text "pretty"?
For example:
I want this..
<person>
<name>Nick</name>
<age>26</age>
...
7
votes
2answers
226 views
Vi mode in other console programs
I quite like the Vi mode of bash. Is there any way to make it work in other programs (gnuplot for instance)?
EDIT: As Shawn suggested below, configuring .inputrc and using rlwrap -a -c gnuplot gives ...
7
votes
4answers
384 views
Bash vi mode configuration to default to command mode
Is it possible to configure bash vi mode so that initially it is in command mode instead on insert mode? I find that I have to press Esc far too much. It seems that there is possibility to specify ...
7
votes
1answer
358 views
Note-taking and outlining using Vi: On startup, highlight tags and display tags in a preview window
I am using vi as a note-taking and outlining tool and therefore I thought that this stackexchange site would be appropriate to ask this question. I am constructing the "tags" file by myself. What I ...
6
votes
4answers
524 views
Indent several lines with VIM?
For eample, I'm editing this code:
<html>
<body>
<script>
var a = 10;
a += 100;
</script>
</body>
</html>
now I need to indent the script line:
...
6
votes
4answers
2k views
delete line in vi
How can I delete a line in VI?
Here what I am doing right now:
Open up the terminal alt + ctrl + t
vi a.txt
I move my cursor to the line which I wan to delete, then what key-combination is should ...
6
votes
4answers
116 views
Replace a line with the line that I have in the buffer in vi
I cc or dd to copy a line into my paste buffer. Then I go to a new location.
I want to replace a line that I see. So I type p Down dd.
Is there an easier way (fewer keystrokes)?
6
votes
1answer
205 views
How can I switch 2 characters in vi?
I like the fact that I've memorized ddp for switching two lines (i.e. dd deletes the line and then p puts it back '1 higher').
Is there are similar set of keystrokes for switching 2 characters so ...
6
votes
2answers
797 views
How different is Elvis from Vim?
I've been using Slackware for a while now, which ships with Elvis as its default editor.
Most other Linux distributions seem to ship with Vim, instead of Elvis. Having gotten quite used to Elvis, ...
6
votes
1answer
502 views
Why is vi apparently broken (viminfo error E576), and how can I fix it?
I am proficient at using Unix/Linux, but I am not an expert. If I want to open a file (for example, file.txt), I use vi:
vi file.txt
This opens the file, and if I want to close it, I use :q!. I ...
5
votes
6answers
195 views
How to select complete file in vi, to be pasted in gedit?
I know that doing %y a will yank complete file into register a. However this doesn't help in pasting the file content in another text editor (say gedit). What alternative is there for doing so?
5
votes
1answer
368 views
As we call `#!/bin/perl` 'shebang', what we call `-*- perl -*-`?
The first line of a script may be in format of #! interpreter, so the shell will execute the script using the specific interpreter. This is so called shebang or shbang.
Similarly, there can be some ...
5
votes
1answer
770 views
How to enable ctrl-R in zsh
I recently switched to zsh (finally) and am loving it!
So far one thing that I am missing is ctrl-R to do incremental history search.
I have the history set up properly
HISTSIZE=10000
...
5
votes
2answers
316 views
Does using ctrl+c instead of esc to exit insert mode break anything in vi?
When using vi, you can exit insert mode with Ctrl + C instead of the more traditional Esc. Are there any situations where it would be undesirable to use for former instead of the latter? Does it break ...
5
votes
2answers
801 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 ...
5
votes
1answer
3k views
Switch VI to use backspace key instead of Control+H for backspace?
I'm on Solaris 10 and by default vi version SVR4.0, Solaris 2.5.0 is installed.
The system was set up so that when I ssh to it Control+H does backspace, and backspace outputs ^?
I added stty erase ...
5
votes
0answers
52 views
Change PS1 without hitting enter [duplicate]
Possible Duplicate:
Change cursor shape (or color) to indicate vi mode in bash
I am using vi-mode in a bash shell, and I would like to change the PS1 variable whenever I am in insert mode. ...
5
votes
3answers
260 views
Search and replace next n words in vi [duplicate]
Possible Duplicate:
Vim :s replace first N < g occurrences on a line
In vi, how do I search and replace a word's first n occurrences with a word, say "hello", and the next m occurrences ...
4
votes
4answers
374 views
xargs and vi - “Input is not from a terminal”
I have about 10 php.ini files on my system, located all over the place, and I wanted to quickly browse through them. I tried this command:
locate php.ini | xargs vi
But vi warns me Input is not ...
4
votes
2answers
127 views
vim customized with emacs commands (insert mode only)
I was an emacs user, and I have to switch to vim. But I miss some basic emacs commands in vim insert mode:
C-A
C-E
C-K
C-Y
C-x C-s
... and some other
I know that I can press Escape and then press ...
4
votes
3answers
164 views
How do I quickly move the cursor to the end in bash in vi mode?
When I'm in insert mode and I move left from the last cursor position (the empty spot to the right of the last character), then I can't go back to that position anymore. I have to type Esc$a (or ...
4
votes
1answer
426 views
How to edit a .gpg file with vi?
So I created a gpg encrypted file with password:
gpg -c passwords.txt.gpg
how can I open it with vi, edit it, then close it? (So that no passwords.txt file will be created, the decrypted ...
4
votes
1answer
109 views
vim: how do I set :match and :2match search results to different colors?
For example, I want something along the lines of:
:match search /<div/ guib=Green
:match search /<\/div>/ guibf=Blue
only that doesn't work.
3
votes
3answers
303 views
vi/vim, how can I write out a number of lines to a new file
I have a bunch of lines that I want to write out to a different file.
How can I do that?
3
votes
5answers
2k views
vi command for adding blank line?
In vi, I can use o or O to add a blank line and go into insertion mode. But what if I want to stay in command mode, is there a command for this?
In googling, I'm seeing suggestions to add stuff to my ...
3
votes
2answers
636 views
How to unset set -o vi?
I wanted to try vi mode in bash but now I would like to change it back to normal.
How can I unset -o vi ?
3
votes
2answers
104 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 ...
3
votes
1answer
2k views
vim: delete lines before cursor
We can delete lines after the cursor (e.g.: the next 3 lines) with:
3dd
But how can we delete the lines before the cursor? (e.g.: 3 lines before cursor)?
3
votes
2answers
76 views
Shortcut for tabn & tabp in vim/vi
When I open several files using vim+tabf, switching across the files will involve using tabp & tabn.
Can I have a quicker way to do so?
3
votes
2answers
254 views
Globally replace Vi with Vim on Fedora
On Debian-based systems the alternatives system handles both the vi and vim executable. So if vim is installed and you execute vi, you also get vim, which I find very nice, because I absolutely hate ...
3
votes
3answers
76 views
console space eaten up by file contents
see the example below to understand my problem ; consider my console prompt look like this
user@server $ ls
"I opened a file temp"
user@server $ vi temp
"temp will open in the same window, when I ...
3
votes
5answers
425 views
vi - how to join differents specific lines
I'm looking for a solution about a "paste" problem on vi/vim .
How to join specific lines in a text file? I have a file like this:
15/10/2011 Revolution day
16/10/2011 About Rome
- differents ...
3
votes
1answer
238 views
Select between given characters in vim
Given three sample lines:
some('lorem _ ipsum');
$some['lorem _ ipsum'];
<span class="some _ class">
(cursor is in _ position)
Which is the fastest way to select (for pasting in other ...
3
votes
1answer
55 views
What is the point of Virtual replace mode in Vim?
The help says that virtual replace mode commands in Vim gr & GR replace characters in screen estate and not in file.
:help Virtual-Replace-mode
I am understanding this as something like ...
3
votes
3answers
123 views
vi / vim - how to automatically strip trailing spaces on save?
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

