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

learn more… | top users | synonyms

7
votes
2answers
445 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 ...
10
votes
4answers
1k 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 ...
0
votes
2answers
34 views

Skip search and replace after a heading in Vim

I have to replace a pattern, but I don't want to replace it after a particular word. This is my program: :vnoremap ::silent! call Bib() function! Bib() %s/\s*\n*{\\&}\s*\n*/ /g ...
6
votes
5answers
1k 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: ...
25
votes
5answers
3k 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 ...
4
votes
1answer
307 views

Vi: On startup, highlight tags and display tags in a preview window

I am using vi as a note-taking and outlining tool. I am constructing the "tags" file by myself. What I would like to do is that when I open my notes or outline file, vi reads the tags present in this ...
6
votes
1answer
83 views

Can I specify the layout of a vsplit command?

When I do the :vsplit command, it always opens the new file on the left side of the screen. Is there a way I can specify I want the new file to open to the right?
0
votes
2answers
30 views

add bracket across numbers at only end of each line

I have a file having lines as: ram_reg_10/raja_reg_9/raghu_reg_8 abc_reg_4/bcd_reg_5 cad/pqr_reg_91 I want to convert string "_reg_number" into [number] at only last of every line in vi ...
20
votes
6answers
2k views

Using VI keys 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 key bindings to edit my shell commands. He placed the command in a file that ran every time I logged in. Since ...
0
votes
2answers
46 views

What is the difference between “find” and “till” in vim?

I see I can use t c or Tc to move to the next / previous character c I can also use fc or Fc to move to the next / previous character c Is the only difference between them that tc places the ...
6
votes
2answers
88 views

In VI how do I paste text into my file from a range of lines I have yanked?

I am using vi in Solaris 10. I am yanking a range of lines by doing 283,295y, and I do believe the yank command is working as it says 12 lines after I execute the command. However when I try to copy ...
6
votes
1answer
205 views

How can I count the number of words in a file whilst editing the file in vim

I know I can use wc for counting characters, words and lines of files at the command line. Is there any way I can can count the number of words while in vim?
1
vote
3answers
74 views

Vim Error 'E212: Cannot open file for writing', when trying to create new files outside of home dir

I am running Wheezy Debian. When I try to create a new file in a directory other than my home directory, such as /var/www, I get the following error in vim: E212: Cannot open file for writing. I ...
2
votes
0answers
33 views

How do you set up a “compiling parser”-like function to help with editing plain scripts in elvis?

I'm using elvis to edit files etc. in a context where limiting the keystrokes makes a difference1. I don't know all the implications of its differences from vim and I'm actually inexperienced with ...
12
votes
3answers
2k 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, ...
1
vote
1answer
80 views

Redirect VI command output to a file

I want to export the output of vi command :set fileencoding to another file. It seems vi's file encoding detection is better than file command. How to do that? I could write a macro with: :set ...
1
vote
3answers
664 views

vi <TAB> completes only directories in bash

In a directory I type vi and then tab (twice), this gives me user$ vi CMakeFiles/ global/ libs/ whereas ls followed by 2 tabs gives me user$ ls ! core.log CMakeFiles/ global/ libs/ ...
5
votes
2answers
515 views

Why does Vi have multiple modes?

Why does Vi have multiple modes? I'm not interested in the functions of the modes unless that was a reason to have different modes. I'm only interested in the design / engineering reasons for ...
2
votes
4answers
1k views

less command and syntax highlighting

I need to use the less command with the syntax highlighting of the vim command for python, C, bash and other languages. How do I apply syntax highlighting colors according to vim colors for less ...
2
votes
2answers
346 views

copy from tmux to any editor not working

I am trying to copy from tmux to my browser. I followed the post Copying between tmux buffers and the system clipboard which tells me to add setw -g mode-keys vi bind-key -t vi-copy 'v' ...
17
votes
5answers
2k views

vim - better colors so comments aren't dark blue?

Mostly I edit ruby files, although shell script file comments are also # Currently my comments show as dark blue on black which is really hard to read. See screenshot. How can I change their color? ...
0
votes
2answers
1k views

Unable to write to file on FreeBSD — read-only filesystem

I bought a load balancer that runs the application on of FreeBSD. I found the configuration file that has all the settings and login information for both the admin and read-only users. I logged in as ...
18
votes
6answers
4k 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?
160
votes
14answers
50k views

What are the pros and cons of Vim and Emacs?

How would you compare these editors? What are the pros and cons of each? [note] This is not meant to be answered by those who "hate one and love another" or those who haven't used both.
4
votes
1answer
76 views

Binding Shift-Enter to insert a newline without evaluating the current expression

I try to bind Shift-Enter to insert a newline without evaluating the current expression in the terminal and in repl modes. Reading through the ArchWiki, I tried setting this in my ~/.Xmodmap file and ...
6
votes
3answers
503 views

vi: move a line by 4 bytes

I want to move a line by 4 bytes using vi editor. What command should I use? I tried ">>" and it does move but it moves by 8 bytes..
5
votes
1answer
372 views

How is `vi` Aware of the Format of Configuration Files?

When I edit configuration files in vi, it seems like vi is aware of the syntax of the file. For example, vi will color tokens one way or another depending on whether its a key or a value. ...
55
votes
3answers
36k 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.
4
votes
3answers
767 views

What does [converted] mean at the bottom of vim?

I have a log file, and when I open it via vim, it looks not readable, and it has [converted] at the bottom. What does [converted] mean? Is there a way to fix the format issue so that it is human ...
9
votes
1answer
2k views

How to enable reverse search 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 SAVEHIST=10000 ...
3
votes
3answers
3k views

backspace in insert mode not erasing characters

I am new to vi, actually I have started learning vi from today and I have got stuck at the behavior of the backspace key. Actually when I fired up vi on my Ubuntu 12.04 for the first time my backspace ...
15
votes
2answers
6k 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?
1
vote
3answers
54 views

Shell vi mode prints (arg: repetition): How to remove it?

Whenever you are in vi command mode on the shell and hit a number, like 8, "(arg: 8)" shows at the start of the line. Anyone know how to make it not do that? The moving the line I'm typing is ...
2
votes
2answers
265 views

How to edit /etc/inittab?

I want to edit /etc/inittab in order to get a login prompt on the serial console once the system boots. By default, inittab file complains to be ro. I tried both gksudo gedit /etc/inittab and sudo vi ...
2
votes
3answers
56 views

Replace string with another string in vi editor

I have a template.php file where I want to change every occurence of apple with grape throughout the file. At the moment,I am having to painstakingly edit the entire file to find where to change. ...
4
votes
6answers
2k views

How to comment multiple lines at once? [duplicate]

How can I select a bunch of text and comment it all out? Currently I go to the first line, go to insert mode then type # left-arrowdown-arrow and then I repeat that sequence, perhaps saving a few ...
0
votes
2answers
82 views

vim how to keep cursor position while copying text

I am (having to) using gvim in windows. I was used to the linux environment where when I select text using mouse the cursor position wont change. Now , with gvim in windows, My problem is something ...
1
vote
1answer
255 views

Plain vi (not vim): Can't delete a line in insert mode: Is this behavior required by POSIX?

In the non-vim implementations of vi I've worked with, it's not possible to delete a line while in insert mode. vim does allows it—but it's my understanding that vim is not POSIX-compliant in ...
21
votes
4answers
3k 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 ...
11
votes
2answers
2k 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 ...
2
votes
1answer
57 views

How to enable 'daw' vi command in zsh?

I've seen that the vi mode option in zsh is rather limited. For example, 'daw' (delete around word) and 'diw' don't work. What is the reason and how can I solve it?
1
vote
3answers
93 views

vim avoid selecting underscore

So I know that an underscore (_) is considered part of a word in vim. Working with Python, I normally end up having a lot of underscores. Is there a way to select part of a word excluding the ...
5
votes
1answer
76 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?
8
votes
5answers
11k 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 ...
4
votes
2answers
54 views

Stop vim from messing up my indentation on comments

For some reason Vim thinks all of my comments should have all indentation removed. If I add # to the beginning of a line, suddenly all leading whitespace is removed. How can I stop this? I have ...
7
votes
1answer
231 views

VIM: folding bullet points

I'm quite new to VIM, but have been trying to teach myself over the past week, yet I'm encountering a problem which has proven to be quite frustrating: Currently I'm mostly using VIM to take notes, ...
12
votes
2answers
633 views

What happens if I use vi on large files?

Though we were instructed not to, a colleague of mine used vi to view a large text file (server.log 3.5 GB). This filled up /var/tmp and caused some problems on the server. What caused this? Why ...
9
votes
6answers
3k 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
4answers
104 views

Symlink everywhere

Is there any way for me to symlink a particular file so that it appears in every directory on the system? So if I symlink /tmp/scratch No matter where I am I can type vi scratch?
2
votes
1answer
207 views

Beep when typing backslash in cvim normal mode

I installed the cvim plugin for vim. Almost all the cvim commands start with '\'. But I when enter this character in normal mode, all I hear is a beep. Nothing happens. What might be causing this ...