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

learn more… | top users | synonyms

2
votes
1answer
34 views

Character class bug in nvi: [[:digit:]] is interpreted like [[:alnum:]]

A simple search in nvi on text such as: the quick red fox jumped 1 foot over the lazy 28 pound dog using the following search /[[:digit:]] behaves like /[[:alnum:]] That is, it finds every ...
1
vote
2answers
18 views

visual mode in vi to remove char at the end of multiple lines

builder.append("sss"); builder.append("aaaaaaaaa"); I would like to remove the ; at the end. I can do it using various scripts in sed or replace all in vim. But, I would like to know how to use ...
7
votes
3answers
2k 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 ...
3
votes
6answers
4k views

How can I check what version of the VI editor I have?

How can I check what version of the vi editor I have? What's the best way to upgrade it or install vim on Solaris?
0
votes
1answer
48 views

Vi editor, search and replace complex string

I want to search and replace particular string in file. Example, the string: ***BNS S&P/TSX60 ROC,SERIES will become: ***BNS S&P/TSX60 ROC SERIES How can I do this?
4
votes
1answer
357 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 ...
18
votes
7answers
5k 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?
7
votes
2answers
427 views

In VIM, replace path with slashes without using escape slashes

In vim I want to substitute a long path /a/b/f/g/d/g with another /s/g/w/d/g/r in a text file. Usually I use \/ but there are too many slashes here. Is there an easier way?
2
votes
1answer
182 views

Expanding text format in VI

The following code is taken from the superfish module for websites: (function($){$.fn.hoverIntent=function(f,g){var ...
1
vote
1answer
46 views

In VIM how do you run a command silently in the background?

I'm using ubuntu and currently have the following line in my vimrc file: nnoremap < leader >dc :execute 'silent !drush cc all' | redraw! The command works but it doesnt hit me back to the ...
27
votes
8answers
3k views

How can I delete all lines in a file using vi?

How can I delete all lines in a file using vi? At moment I do that using something like this to remove all lines in a file: echo > test.txt How can I delete all lines using vi? Note: Using dd ...
10
votes
5answers
2k 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 ...
4
votes
1answer
30 views

Initializing search in vi before starting

I use a small program I wrote that takes a regular expression pattern as parameter and searches 2000+ files. The files are in a directory hierarchy. The pattern can be in multiple files and multiple ...
0
votes
1answer
30 views

Does VI v4.0 on Solaris 2.5.0 have a command history

I normally use VIM but have to fiddle with files in VI. Does the vi on Solaris 2.5 have history I can recall to re-use commands? It's a pain to retype complete lines sometimes. In VIM I can go ESC, ...
2
votes
2answers
72 views

how to recall last argument in bash with vi setting

I use set -o vi setting in bash. The shorcut Alt+. (recalling last argument of previous command) here doesn't work as in emacs mode, so what is the equivalent for vi?
1
vote
1answer
80 views

What is happening while executing this command cd / | vi?

When I execute the command cd / | vi, it goes to the vi editor. When I type any command it does not display the command but it gets executed and the command that is executed is not shown in the ...
4
votes
3answers
5k 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 ...
2
votes
1answer
26 views

Reverse global and local marks in vi/vim

How can I reverse the capitalization convention of marks in vi/vim? Normally a lower-case mark like "a" means it is local to the current file, but upper case marks like "A" are global to the session. ...
5
votes
3answers
1k views

vim - how can i do a 'change word' using the current paste buffer

I have some text in my paste buffer, e.g. I did a yw (yank word) and now I have 'foo' in my buffer. I now go to the word 'bar' and I want to replace it with my paste buffer. To replace the text ...
-2
votes
1answer
70 views

Why are there several keys unbound in vim?

There are several keys that are unbound in vi/vim, such as g, q, v and #. Is there a particular reason why these keys are unbound? Can I just use them however I want or will I be breaking certain ...
7
votes
2answers
509 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 ...
0
votes
2answers
38 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
2k 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 ...
6
votes
1answer
106 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
42 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
3k 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
52 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
110 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
305 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
585 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
41 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 ...
13
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
185 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
803 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
528 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 ...
6
votes
4answers
3k 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
605 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' ...
19
votes
5answers
8k 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
2k 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 ...
172
votes
14answers
67k 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
138 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 ...
5
votes
3answers
515 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
393 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. ...
67
votes
3answers
47k 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.
10
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 ...
16
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
73 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
880 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
91 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. ...