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

learn more… | top users | synonyms

3
votes
1answer
792 views

How to insert both vimscript variable and string into vim search and replace

I've only just found out about Vimscript's existence as of today, so forgive me if this question is more basic than it seems, but I've been struggling to find an answer to this question for the better ...
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? ...
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
226 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 ...
12
votes
5answers
11k views

Delete 100 lines from vi editor using single command

I am using Ubuntu and trying to delete all 100 lines from vi editor but I got interview question of doing this in one command.
1
vote
1answer
112 views

How to know I am using vi or emacs input?

Crash shell allows to specify the command line editing mode to vi or emacs. What will be the difference in these input methods? I am not asking about the internal features.
6
votes
7answers
3k views

Uncommenting multiple lines of code, specified by line numbers, using vi or vim

I have learned from this Stack Overflow question that it is possible to use vi/vim to comment out a specified range of line numbers. For example, suppose I have the following bash script: ...
0
votes
1answer
109 views

Gnu Screen and vi - visualization issues

The scenario is as follows: gnu screen launched onto a scientific Linux distro ssh to an aix machine tried to edit a file with vi And this is what I got: "ex: 0602-108 screen is not a ...
4
votes
3answers
1k views

Change the text on a single line number in multiple text files

Suppose that I have ten bash shell scripts: script1.sh, script2.sh, ..., script10.sh. Initially, all ten files are identical. Now, I would like to make two changes in each script: In each file, ...
-2
votes
1answer
47 views

how do I save my buffer in vi without exiting?

how do I save my buffer in vi without exiting? .
-2
votes
2answers
311 views

Joe,pico,emacs missing

I've installed a 'linux in a box' at home using FreeBSD and Virtual Box.But when I tryed to make a C file,joe,emacs and pico give me 'Command not found'. joe z.c,emacs z.c, pico m.c are the commands ...
0
votes
1answer
454 views

How to change search result highlight in vi?

The scenario: I log on a server using ssh, and search for keywords in a log file using vi. The problem: at the moment, the results of a search is only highlighted by a cursor _ below the searched ...
5
votes
1answer
464 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 ...
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 ...
6
votes
3answers
3k 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
0
votes
1answer
112 views

vi / vim - extra indents when pasting text? [duplicate]

I can copy characters in other apps such as browsers with ctrlc. I can then press i to enter insert mode in vim and press shiftctrlv to paste the text in. The problem is that each line gets indented ...
5
votes
3answers
409 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
2answers
626 views

vim shortcut to open a file under cursor in an already opened window

In vim you can open a file under the cursor by using the gf command. One can also easily open that file in a new split window by hitting <c-w> f. This is a really nice and time saving feature. ...
5
votes
1answer
424 views

Custom key bindings for vi shell mode, ie, “set -o vi”?

I just discovered the wonders of set -o vi, and am curious if it is possible to customize this vi shell mode in some of the same ways you can customized vi or vim? For example, create a custom key ...
6
votes
2answers
6k views

How can I set “vi” as my default editor in UNIX?

I believe I can do something like export EDITOR=vi, but I'm not sure what exactly to enter, and where. How can I set "vi" as my default editor?
1
vote
1answer
123 views

vi - search the string you cursor is over?

I looking more for a method that is "built-in" to vi, and not something that I could do in my .vimrc. Though, solutions for .vimrc are appreciated. :-) When I want to search a string, sometimes that ...
1
vote
2answers
752 views

How do I set vim as the default editor when I sudo?

I'm working on a CentOS 5.9 machine, and I simply want to type sudo vi somefile and have my trusty vim with syntax highlighting, etc. This seems simple enough, but after many attempts, it's ...
2
votes
1answer
1k views

Vim - how to increase each number in visual block?

I have the following SQL: update am.PERMISSIONS set PRM_ORDER = 35 PRM_VISIBLE = b'1' where PRM_ID = 3; update am.PERMISSIONS set PRM_ORDER = [35] PRM_VISIBLE = b'1' where PRM_ID = 7; update ...
1
vote
2answers
924 views

How do I set bash aliases and variables from within vim?

In cmdline mode, the following examples do not work for me. !alias lol='echo lol' !lol='echo lol'
1
vote
1answer
549 views

vi backspace problem

I have to work on a really old AIX workstation with vi version 3.10 in it. I have done a little work in vim, but that was much more easy to use than the old vi (atleast untill I get used to the old ...
1
vote
0answers
255 views

set hlsearch not working in vi

I want the result to be highlighted when I search for it in a file.So,I opened a file with vi(version 7.2) and then used command :set hlsearch to enable highlighting.But even then I don't get my ...
5
votes
6answers
5k 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?
2
votes
3answers
98 views

Ctrl+W in vi[m] to erase to whitespace

I want to mimic the functionality of bash readline in vim. Is there an easy way to do that? Currently in vim Ctrl+W "cuts" from cursor back to special char or whitespace. ie. In bash Ctrl+W "cuts" ...
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 ...
2
votes
1answer
32 views

messages appearing when not desired

I have SSH access to a CentOS box and I have a strange behavior of that box, I have never seen before. Lets say I am editing a file with vi or displaying tail -f of a file. Every time the server has ...
3
votes
4answers
193 views

What are some of the main differences between vim and vi?

What are a few of the main differences between vi and vim? Are there any significant keyboard shortcut differences, any features that one has that the other does not? Yes, I do know that I asked ...
9
votes
1answer
2k 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> ...
0
votes
1answer
193 views

Write out without quitting in Vim?

I looked through the vim manual, and I could only find the commands for "write and quit" and "write (if edited) and quit". Is there a command for "write out without quitting", similar to ^o in nano?
3
votes
2answers
211 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 ...
2
votes
1answer
3k views

How to enter non-ascii characters using hex or octal codes in vi

I'm trying to write a golfing library for postscript. But it needs to be condensed itself. So I need a convenient way to type-in arbitrary bytes within mostly ascii text. I know this can easily be ...
20
votes
6answers
12k 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 ...
2
votes
4answers
209 views

Disable vi from going to the last visited line upon file opening

Is there something I can put in my exrc file to prevent vi from going to the last line I was on last time I had the file open and just set the cursor at the top by default? I think it is ...
9
votes
2answers
4k 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 ?
12
votes
2answers
3k 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
2answers
2k 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 ...
2
votes
1answer
59 views

remotely query text file associated with an instance of vi

I have opened several text files (a.txt, b.txt, c.txt, ...) in different sessions of vi launched from different instances of a bash shell. Having then accessed that machine remotely, I wish to ...
2
votes
2answers
116 views

Bash Vi-mode: Move back to last slash

I'm using Bash in vi mode with set -o vi. Often I re-run a command but need to change the name of a file in the same directory. Example: mv /tmp/myfileA.txt /home/daniel/myfileA.txt Then, I ...
6
votes
2answers
824 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
0answers
55 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. ...
1
vote
3answers
805 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/ ...
3
votes
3answers
461 views

Sed processed file displays differently in vi vs cat

I can't tell if sed is mucking my file up. In vi or less it displays properly, but cat and more insert other characters. why are they showing up differently I am on a redhat linux system with a ...
3
votes
2answers
126 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?
1
vote
2answers
242 views

concat file content horizontally in vi/vim

I have a text file that contains a big matrix, that columns are split like the following example: col1 col2 col3 row1 .. .. .. row2 .. .. .. row3 .. .. .. row4 .. .. .. row5 ...
6
votes
2answers
499 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 ...
3
votes
2answers
2k views

git commit error - cannot run vim: No such file or directory

$ git commit error: cannot run vim: No such file or directory error: There was a problem with the editor 'vim'. Please supply the message using either -m or -F option. How can I overcome the error ...