vi is a text editor of the Unix operating system.

learn more… | top users | synonyms

29
votes
9answers
86k views

How do i select all text in Vi/Vim?

I always use vi for editing config files. Today I wanted to select all the text in a file (around 1000 lines), copy it, then paste into Google Docs. How can I do that?
15
votes
6answers
17k views

Vim to replace Vi

Guys, anyone know how to change linux console editor from vi into vim everytime we execute vi? I'm using Ubuntu and Fedora Core
13
votes
4answers
1k views

Inserting a blank line in vim?

I quite often find I have a need to insert a blank line either below or above the current line when editing in vim. o and O will do this, but they subsequently switch into insert mode, which is ...
12
votes
13answers
1k views

What Vim features do you use? [closed]

I spend almost all day programming in Vim and I am sure that a lot of you do too. What features do you use that make your day to day coding that much better? One that I use is gv, which will let ...
12
votes
2answers
2k views

How to use a pipe to edit a file with vi

Lets say I have a file called file.txt. In it is a name of a file that I want to edit with vi. I want to do something like this so that I can edit the file: cat file.txt | vi However, that doesn't ...
12
votes
5answers
2k views

How to show the current Vi mode when using Vi keybindings in the shell?

I use the vi keybindings in my tcsh shell. Now, I don't know which vi mode I'm in (insert mode or command mode), which leads to a lot of frustration. Does anyone know of a way to show the current ...
11
votes
1answer
3k views

How to switch comfortably to vi command mode on the zsh command line?

In vi, I have mapped 'jj' to escape to be able to switch to command mode without using the annoying escape key. Now I want to have the same for command line editing for which I use vi-mode. I already ...
10
votes
3answers
2k views

Any IRC clients with VI key binds?

Is there any IRC client that supports VI keys? The ''obvious'' script VimIRC is and has been broken for so long it's not even funny. Do you know any IRC clients on Linux, GUI or Curses, that provides ...
10
votes
2answers
107 views

vi / vim abrumpt buffer movements within window

When using :set wrap in vi/vim, the contents of an entire wrapped line are placed in the display buffer upon moving the cursor into a new line, even when navigating through a file by display line ...
8
votes
3answers
722 views

vi: how can I jump to end of file with a new line appended?

Here's an answer I want about 5 times a day. In vi, the command to go to the end of the file is G. But that always leaves me at the start of the last line of the file, if files don't have a blank ...
7
votes
4answers
10k views

How to get rid of the warnings when opening a file that has a .swp file?

How can I get rid of the annoying warnings when I open a file that has a .swp file? Or, how do I not generate the .swp files at all? Example warning: E325: ATTENTION Found a swap file by the name ...
7
votes
1answer
1k views

vi: what is verbose mode and when/how do I use it?

Sometimes When I'm using vi I accidentally hit caps lock when I'm in command mode. This apparently puts vi into verbose mode which I'm having trouble finding documentation about how to use. How and ...
7
votes
2answers
406 views

Readline in vi mode: how can I enable up/down arrows?

When bash has vi bindings available (set -o vi), up/down arrows work in both command and insertion mode. When I setup readline's ~/.inputrc to use vi mode (set editing-mode vi), applications like ...
6
votes
5answers
5k views

Is there a VI equivalent I can use on Windows XP and later?

I get frustrated using Notepad on my Windows XP machine when I want to do more complicated text manipulation. Having used VI on various versions of UNIX I'd like to get something with its power on my ...
6
votes
2answers
275 views

Is it possible to control the whole Gnome desktop with vi-like commands?

I know with readline you can use emacs or vi commands to edit the input of several interactive text programs. I wonder if there exists such a similar facility to control the whole desktop in Gnome or ...
6
votes
1answer
773 views

How can I edit a google doc with vi and automatically update the original doc in the cloud when I write the file?

I'm using ubuntu 11.04. I have installed googlecl which claims to allow me to edit google doc files with vim. I have a google doc "test": google docs edit --title "test" --editor vim opens the file ...
5
votes
3answers
1k views

Logged in to vi, made changes, forgot to sudo first - now what

I made lengthy changes to a configuration file on a Ubuntu Linux computer with the vi editor. Unfortunately, I forgot to sudo first, so now I'm in the editor, but can't save my changes because of ...
5
votes
8answers
392 views

vi / vim tutorial recommendations

Being a common tool for *nix System Administrators, I'm looking for recommendations for vi/vim tutorials. After seeing this 'how do I do [this] in vim' question in Stack Overflow, I realize that I ...
5
votes
4answers
3k views

vi visual mode doesn't work

I'm running vim (7.0.237) after sshing to a remote CentOS box, and it just won't enter visual mode. When I press 'v', it just beeps and does nothing. I'm running Ubuntu with GNOME Terminal, and the ...
5
votes
3answers
1k views

Linux: How can I edit all the files returned by find in vi?

Something I find myself doing a lot is running a find command and then editing all of them in vi, which looks something like this: > find . "*.txt" ./file1.txt ./file2.txt ./path/to/file3.txt ...
5
votes
4answers
5k views

How to get vim color mode to work in vim under cygwin

I have installed vim 7.3 under cygwin. And I have this in my ~/.vimrc $ cat .vimrc colorscheme wombat And then I have this file wombat.vim under '.vim/colors'. $ ls -la .vim/colors/ total 8.0K ...
5
votes
2answers
409 views

Edit text areas using vi key bindings, inside the textbox, in Firefox (without opening a separate window)

I'm using Firefox. Is there any way to edit the contents of a textbox using vi key bindings, inside the text area (not in a separate window)? For instance, is there a Firefox extension for that? I ...
5
votes
1answer
667 views

Close VIM session over ssh

I work remotely some days and I left vim open with some unsaved changes at the office. Now I'd like to save and close those sessions so I can work on those files at home. I am logged into that machine ...
4
votes
2answers
2k views

Moving the the very bottom of the file with vi

No, I'm not talking about vim, I'm talking about old-school vi; because in vim you can actually issue a :bot and it'll move to the bottom of the file.
4
votes
1answer
220 views

how do I go from typing `/foo` to `:%s/foo/bar` efficiently

In vim, I typed /foo Enter and found some matches. Now I want to replace all instances of foo with bar (i.e. :%s/foo/bar). Can this be done without retyping the foo? (e.g. into the command line ...
4
votes
6answers
7k views

UNIX - How to copy and paste between different bash windows with files opend with VI?

Lets say I log in to bash, open a file in vi, then using alt-f2 I open a new terminal. After logging in I navigate to a second file and open that in vi. How can I CnP between these two files? I found ...
4
votes
1answer
317 views

Hiding vim command-line when it's not being used?

Is there any way to hide the vim command-line (ideally, automatically) when it's not being used? On small screens it takes up one valuable line. I'm thinking it would be 'normally' hidden, and appear ...
4
votes
2answers
1k views

Error location navigation in Vim Syntastic

I've got Syntastic installed in Vim and it is finding errors perfectly (mostly in Python code I'm working on). If I jump around normally in the file I see the errors in the status bar when the cursor ...
4
votes
1answer
6k views

Vi on Linux: show ^M line endings for DOS-format files

On Solaris, if you open a file in vi that has Windows line endings, this shows up as ^M at the end of every line. On Linux, vi is cleverer and understands the Windows file format, and does not ...
4
votes
5answers
730 views

In Vi, how do I map “:t” equal to “:tabnew”?

I don't want to always type the word. it's annoying.
4
votes
2answers
118 views

Getting vi/vim syntax highlighting used by certain user

At work most web-development we do, is done in vi/vim, on a debian-server. Sometimes we have to alter some files as root, and the syntax-highlighting-model of that user (root) is absolutely awesome. ...
4
votes
1answer
2k views

How to pass vim buffer contents through shell command and capture the output to a split window

I've read lots of threads about running shell commands from vim, lots of documentation on vim commands, .vimrc and all that, but I just can't seem to understand the "ex" language or vim mappings well ...
4
votes
3answers
3k views

Display invisible characters in vim

When I compile my source with Latex, I get the following error message Unicode char \u8:  not set up for use with LaTeX. Now I suspect that this is due to an invisible character. The command ...
4
votes
2answers
115 views

Escape not idempotent in zsh's vi emulation?

I have zsh configured to use vi keybindings. I've noticed some unexpected behavior with "escape". In vim (I haven't tested vanilla vi) if I hit escape twice, I can hit 'i' once to return to insert ...
4
votes
2answers
762 views

Whats the difference between vi editor in Red Hat linux and Ubuntu?

I realize a difference in vi editor of ReD Hat and Ubuntu. In my company, I'm working in Red Hat. In that, the vi editing commands working as usual. Say, 'dd' to delete,'p' to paste, 'yy' to yank, ...
4
votes
1answer
140 views

Abort a vim paste

Sometimes I paste a lot of data into vim (>5000 rows) and forget to enable paste mode. In that case, vim is busy for several minutes, trying to correctly indent all the text (which gets REALLY bad ...
4
votes
3answers
1k views

Vi-Vim like control keybindings for Windows

I've been using gVim for a while and love the interface. I'm in love with my keyboard-fu skillz. I was wondering if there was any application that would extend its functionality to all parts of ...
3
votes
9answers
1k views

emacs or vi which should a windows user learn?

I am currently reading a book on bash and it recommends learning either emacs or vi. I am primarily a windows user and not very experienced with linux yet. So which would be best to learn, or is there ...
3
votes
4answers
351 views

Indenting an X number of lines in vim

I've been coding in Java for a job recently and I've noticed that I'll write some code and then determine that I need to wrap the code in a try/catch block. I've just been moving to the beginning of ...
3
votes
2answers
590 views

vi/vim alternative to sublimetext's “Expand selection to scope”

Sublime text has a cool feature called "Expand selection to scope" SHIFT+CMD+SPACE which selects the everything within the scope. It select everything in scope, works perfectly ( ) or [ ] or { } ...
3
votes
3answers
96 views

VI adding # moves cursor to beginning of the line

Why does vim move me to the begining of a line when I press # for a comment or remark say in a perl file? Why would I not want my comment to be indented at the same level of the current code?
3
votes
2answers
1k views

Create file with 751 permissions at creation

I keep creating practice perl scripts in a linux directory using vi <filename> and need to chmod 751 <filename> before I can run it as I wish to. I'm sure there is a simple way to default ...
3
votes
3answers
7k views

How can I enable backspace key in VI?

I have bare-bone FreeBSD installation. No package installed. And VI doesn't accept backspace key. (I pressed backspace key but nothing happen) How can I enable backspace key in VI? Oh, and I'm using ...
3
votes
3answers
6k views

changing the color of comments in vim

I use vim to browse the source code. In java source files comments appear in blue color on black background which is difficult to read, how to change this color scheme so that comments can appear in ...
3
votes
2answers
111 views

vi swap file is empty

If vim crashes and leaves me with a .swp file that is empty (i.e., file size = 0), does that mean I didn't make any changes to the file during the session in which my computer crashed? If so, then is ...
3
votes
1answer
227 views

bash vi mode: what is (arg: N)?

I am using vi mode in a bash shell. If I enter insert command mode and type a number from 1-9 (eg: 5, in the example below), I get the following prompt: (arg: 5) <cursor> What does this ...
3
votes
1answer
210 views

How to cut and paste tabbed lines with auto indent set to on in vi

Not sure which stack exchange group this question goes so please move to the correct one if this is the wrong one. What's happening is if I highlight something with tabs/indents from one ...
3
votes
2answers
213 views

How to delete password in vim without storing it in a register?

I have a password in a text file. I'm editing the file in vim and I want to delete the password. If I just delete it, say with 'dw', it's stored in several registers. I want to avoid keeping any track ...
3
votes
3answers
2k views

How to copy and paste between cygwin's vi/emacs and windows clipboard?

I tried to paste what I copied in windows clipboard into cygwin's vi or emacs, and it doesn't seem to work with yy (vi) or M-w (emacs). Is there a way to do it? I learned that /etc/clipboard has the ...
2
votes
4answers
195 views

In vim, what keystrokes (did I accidentally hit to) bring up :'<,'> and how do you set those marks?

I fumbled in vi and briefly saw this at the bottom of the screen, just as I was hitting ESC: :'<,'> Like it was ready for me to type an arbitrary ed command over a range spanned by the marks ...