vi is a text editor of the Unix operating system.

learn more… | top users | synonyms

37
votes
9answers
106k 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?
17
votes
6answers
19k 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
2answers
3k 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 ...
13
votes
4answers
2k 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
5answers
3k 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
4k 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
3k 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
117 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
1k 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 ...
8
votes
2answers
439 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 ...
7
votes
4answers
7k 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 ...
7
votes
4answers
12k 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
2k 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 ...
6
votes
5answers
6k 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
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 ...
6
votes
3answers
2k 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 ...
6
votes
2answers
326 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
902 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
8answers
412 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
2answers
3k 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.
5
votes
2answers
784 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 { } ...
5
votes
3answers
503 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
3answers
4k 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 ...
5
votes
1answer
731 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
1answer
249 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
434 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
2k 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
7k 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
855 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
119 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
2answers
130 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
805 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
154 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
369 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
4answers
4k views

Always use :set paste, Is it a good idea?

In a terminal vim, pasting clipboard data often messes up the code indent. I just knew if I uses :set paste the indent is not broken. Though, after pasting data, should I do :set nopaste again? What ...
3
votes
1answer
290 views

Vi: how can I paste the last string of text that I entered when I was in insert mode?

How can I paste the last string of text that I entered when I was in insert mode? I think I've done this before on accident but I can't recall how.
3
votes
3answers
97 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
625 views

Exclude dash (-) from word separators in vi

vi uses dash and space as word separators. is there any way to exclude dash from word separators ? This is required to work with the symbols generated by ctags exe. when symbol contain a "-" ,vi tags ...
3
votes
2answers
2k 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
131 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
2answers
243 views

Why provide vi and vim?

I think I'm right in saying RedHat and other distributions provide both vi and Vim. Does anyone know what the rationale is behind providing both when presumably if Vim is provided it covers the ...
3
votes
1answer
249 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 ...