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

learn more… | top users | synonyms

-5
votes
0answers
29 views

shell script to read a log file and display in a readable / good format [on hold]

I need to read a log file which contains date,time,error_name, pid,program crash details and others content. log file is supplied as input file to the script and output should display in following ...
1
vote
1answer
72 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 ...
1
vote
2answers
28 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?
2
votes
1answer
21 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. ...
-2
votes
1answer
54 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 ...
0
votes
2answers
35 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
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
35 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 ...
0
votes
2answers
47 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
90 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
217 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
116 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
40 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 ...
1
vote
1answer
112 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 ...
5
votes
2answers
516 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 ...
4
votes
1answer
94 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
506 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
376 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. ...
4
votes
3answers
938 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 ...
1
vote
3answers
58 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
398 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
59 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. ...
5
votes
6answers
4k 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
87 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
293 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 ...
2
votes
1answer
60 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
99 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
78 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?
2
votes
2answers
412 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' ...
4
votes
2answers
57 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 ...
12
votes
2answers
694 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 ...
7
votes
1answer
242 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, ...
1
vote
4answers
105 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?
1
vote
2answers
65 views

How can I go forward in a file? What is the oposite of ctrl+O

If I jump to a file e.g. by gf I know that I can do ctrl+O to go back. But how do I go forward? I.e. what is the opposite of ctrl+O so as to go forward to the file I was earlier to which I jumbed to ...
2
votes
2answers
145 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.
9
votes
6answers
4k 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 ...
0
votes
1answer
306 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
100 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 ...
1
vote
1answer
75 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
260 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 ...
2
votes
4answers
2k 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
1answer
118 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
223 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
601 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 ...
17
votes
5answers
3k 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
721 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
173 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
7k 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
110 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.
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: ...