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

learn more… | top users | synonyms

2
votes
2answers
141 views

Make script executable from vi/vim

How can I run chmod +x on the script I'm creating in vi/vim so that it is executable? I tried :r chmod +x % but it didn't work.
0
votes
1answer
276 views

Vi editor behaving randomly while editing

When I open a PuTTY session in full screen I can't scroll down and up properly with the down arrow key. It seem to move down the screen and gets stuck somewhere in the middle. When I open PuTTY in ...
5
votes
2answers
98 views

vi: how to use a line as a command?

cat a.txt echo hi echo hu echo ha Q: how can I execute ex.: the second line in a.txt when it is opened with vi? so "vi a.txt" -> then SOMEMAGICCOMMAND -> then the "echo hu" is executed as a ...
4
votes
3answers
578 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 ...
1
vote
1answer
72 views

Can vim warn on a tabpagemax overflow?

If I open a collection of files in vim tabs using a glob pattern, I'd like to be warned if the number of files matching the pattern exceeds the value of tabpagemax. For example, if the following, $ ...
4
votes
2answers
223 views

VIM substitute occurrences of pattern after a particular word in a line

I have such lines in my text. text before pattern = garbage** text after pattern is pattern If in VIM I do %s/pattern/saturn/ it replaces all occurrences of pattern. But I only want to replace ...
1
vote
3answers
2k 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?
12
votes
5answers
5k 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.
2
votes
1answer
115 views

How to edit the file content in vi?

I have a text file with following content (Actual filecontains thousands of lines) abcd xyas sasss jddks asa sasa lkkkss asasd I want the output in the folloing format. abcd xyas sasss jddks asa ...
5
votes
1answer
211 views

In Bash Vi mode, I get thrown into Insert mode automatically after one key press

I am using the bash shell with the XFCE4 terminal. I have configured the shell so that it is in Vi mode. I have done this by adding the following line in my ~/.bashrc file: set -o vi When in a ...
3
votes
1answer
528 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 ...
2
votes
1answer
170 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 ...
0
votes
2answers
475 views

Vi for Cygwin syntax

How can I make vi in Cygwin highlight the syntax when I open a file by default? I know that I can type in the command "syntax on" but I would prefer to not do this all the time.
5
votes
7answers
2k 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: ...
6
votes
1answer
270 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.
1
vote
1answer
107 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.
0
votes
1answer
86 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
783 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
2answers
227 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 ...
-2
votes
1answer
45 views

how do I save my buffer in vi without exiting?

how do I save my buffer in vi without exiting? .
0
votes
1answer
299 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
3answers
357 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 ...
5
votes
1answer
363 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 ...
5
votes
3answers
2k 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
96 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 ...
7
votes
1answer
5k 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 ...
4
votes
2answers
373 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. ...
1
vote
1answer
455 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 ...
5
votes
1answer
317 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 ...
2
votes
2answers
3k 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
95 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
605 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
727 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
621 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'
5
votes
2answers
393 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 ...
5
votes
6answers
3k 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?
6
votes
5answers
4k 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 ...
0
votes
0answers
197 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 ...
19
votes
9answers
2k 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.
2
votes
1answer
2k 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 ...
2
votes
3answers
97 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" ...
3
votes
4answers
175 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 ...
0
votes
1answer
177 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?
2
votes
1answer
31 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 ...
4
votes
2answers
1k 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 ...
9
votes
1answer
1k 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> ...
19
votes
6answers
8k 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 ...
3
votes
2answers
159 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
4answers
188 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 ...
7
votes
2answers
3k 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 ?