vim (Vi IMproved) is a text editor supporting different editing modes.

learn more… | top users | synonyms

12
votes
4answers
2k views

Replacing Multiple blank lines with a single blank line in vim / sed

Question more or less says it all. I'm aware that /^$/d will remove all blank lines, but I can't see how to say 'replace two or more blank lines with a single blank line' Any ideas?
29
votes
8answers
21k views

How to copy text from vim to an external program?

I'm trying to copy-paste some text from vim. I'm doing v to enter visual mode, then y once I selected my block. It appears to copy the text into vim's clipboard, because p will paste it. But in ...
5
votes
2answers
809 views

How to do a text replacement in a big folder hierarchy?

I want to search and replace some text in a large set of files excluding some instances. For each line, I want a prompt asking me if I need to replace that line or not. Something similar to vim's ...
4
votes
1answer
469 views

How to use Filetype in Vim?

In most cases, I want to use tabstop=4 while editing files. But for some types of file, like xml file, I want to use tabstop=2. I added au filetypedetect FileType xml,html,xhtml,javascript set ...
2
votes
1answer
218 views

Vim config for specific filetypes

I'm struggling with using .vimrc to apply specific configurations based on the filetype. Following the autocmd FileType suggestion here, I have attempted to apply a configuration based on filetype. ...
5
votes
1answer
666 views

Trying to get vimpager (to replace less) working with nerdTREE

I'm trying to get switch over to vim as my primary editor and I've installed the nerdTree plugin, but now when I try and use vimpager to replace less I get Error detected while processing VimEnter ...
3
votes
2answers
1k views

How to map one vim command to execute bash commands based on OS?

In short, can single bash commands in the terminal contain conditionals? If so, how? I have in my vimrc (shared across systems) the following command to open my current LaTeX document in .pdf form: ...
9
votes
6answers
6k views

Are cygwin vim commands different than normal vim?

I am unable to edit text files using vim in cygwin. I have to press i many times to insert text. Sometimes it works and sometimes doesn't. Whenever I move cursor up down I have to press I many times. ...
25
votes
5answers
3k views

Why does `ESC` move the cursor back in vim?

In vim, when I hit ESC to return to command mode, the cursor moves one character to the left. This is not what I would hope for, occasional I immediately hit l to move back to that spot, perhaps to ...
8
votes
5answers
13k views

delete line in vi

How can I delete a line in VI? Here what I am doing right now: Open up the terminal alt + ctrl + t vi a.txt I move my cursor to the line which I wan to delete, then what key-combination is should ...
37
votes
5answers
3k views

Becoming root from inside Vim

Sometimes I start editing configuration files in /etc using Vim, but forget to use sudo to start Vim. The inevitable result then is that after finishing my edits I encounter the dreaded notice that I ...
6
votes
1answer
848 views

Is there an equivalent to whitespace-mode in emacs for vim?

Is there a way I can see spaces and tabs wonderfully visualized in vim, like I can in emacs by toggling whitespace-mode?
5
votes
3answers
1k views

Vim: word wrap for documents

Whats the best way to do word wrapping for a document in vim? I'd like have each line wrap at 80 characters, not just visually wrap but enter a newline. I got this kind of working by using :set wrap ...
3
votes
2answers
752 views

The Right Distro for text-based needs

I'm searching for the right Linux Distro. My four current ideas are: Gentoo Grml Arch Debian But I'm absoluty open to more alternatives. Now a little bit more about my needs: I want it to be ...
2
votes
3answers
755 views

Unmet dependencies

I am trying to compile vim and install with "--enable-pythoninterp" flag, which needs the python-dev package. INFO I obtained the vim source from ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2 Vim7.3 ...
2
votes
4answers
7k views

How can I find and replace with a new line?

I have a CSV delimited by commas and I want to delimit it by newlines instead. Input: a, b, c Output: a b c I've written Java parsers that do this stuff, but couldn't this be done with vim or ...
4
votes
1answer
287 views

Why is Vim eating up Ctrl when used with Ctrl+v and how to fix it?

I'm using Vim /etc/zsh/zshrc to add key bindings for zsh because it doesn't work with inputrc. In my terminal with tmux when I type Ctrl+v then Ctrl+LeftArrow the shell will show ^[OD. However, when ...
9
votes
2answers
613 views

vim: use string from search in replace command

I often use vim / search command to verify my regular expressions (just to see what it matches). After that i usually use the :%s replace command, where i use that regexp from search as a string to be ...
5
votes
2answers
1k views

Is it possible to run a Vim clientserver instance over SSH+tmux

I've been a vim junkie for a year or so now and I've got some great little tricks burnt in to my memory. I do a lot of development (at the office) in a terminal on Ubuntu. One of the things I value ...
4
votes
1answer
846 views

GNU Screen makes Vim ESC key slow

Screen makes my ESC key wait for more commands I beleive, and if it does not get those commands, it sends it to my terminal Session (which I am running VIM in). ESC is used alot in VIM and currently ...
1
vote
1answer
317 views

Ctrl + Right and Right send same Sequence in Putty > Screen > Vim

I'm using putty > screen > vim, and screen is sending the same sequence for Ctrl+Right and Right in application mode for vim. There is an option to make putty send the cursor mode sequences ...
2
votes
2answers
266 views

Specify an alias as preferred editor in rc files (like .cvsrc)?

I have in my .cvsrc: cvs -q -e vim I want to create an alias (like my-vim or something like that): alias my-vim="vim -S ~/myscript.vim" And do cvs -q -e my-vim Unfortunately, this doesn't ...
2
votes
1answer
379 views

How to stop Vim from changing my directory when executing a makefile?

OK, I posted this question before I knew the extent of what was happening. Suppose I have a mix of Python and C++ code. I use a simple makefile which copies the files from my editing directory to ...
5
votes
2answers
6k views

“No protocol specified” when running vim with sudo

Recently I start to get "No protocol specified" when using sudo vim. It's just a warning I guess, because everything was working normally (I can open, edit and save files). The message doesn't appear ...
12
votes
5answers
5k views

How to insert the result of a command into the text in vim?

For instance, :echo strftime(%c) will show the current time on the bottom, but how to insert this time string to the text (right after the cursor)?
7
votes
8answers
3k views

Compiling code from vim

New to vim and and I want to be able to compile code from within vim without running a new terminal and calling the compiler. How do I go about doing this? Note that this requirement is not ...
8
votes
2answers
384 views

vim: Can I make *only* y perform a copy?

I'm learning to like vim, but one thing that I haven't yet fully embraced is the copy and paste situation. In a muggle text editor I would Ctrl-C copy a piece of text and then edit/delete and then ...
13
votes
1answer
7k views

How to make Vim display colors as indicated by color codes?

In short, I'm in an effort to replace less with vim (vimpager). I have settings for scripts to spit out colors (and bold and everything nice) whenever they can. less understands the color codes and ...
3
votes
1answer
239 views

`man ascii` is misaligned when using vim as a pager

To use Vim as a pager for man I have export MANPAGER="/usr/share/vim/vim73/macros/manpager.sh" in my profile. Now man pages look very good with colors and stuff. However, when trying man ascii as a ...
6
votes
4answers
1k views

vim search around line breaks

When I am editing a LaTeX document in vim, often times I want to search for a phrase. Because I have LaTeX setup to wrap lines, sometimes half of the phrase will be on one line while the other half ...
3
votes
1answer
2k views

What packages are required to install vim on Fedora?

What RPM packages are required to install vim on a recent version of Fedora?
3
votes
1answer
407 views

vim -N mode: where to use it?

I am following the Peepcode screencasts to learn vim. The presenter mentions about the -N mode but doesn't elaborate it much and says that it should be the default mode. My questions: What is the ...
8
votes
1answer
1k views

screen + vim — Any way to automatically set screen window name to open vim filename?

I have a pretty nice screen rc file that shows me the open screen windows almost like tabs at the bottom of the terminal. Currently the windows are named according to my prompt which is not so useful. ...
10
votes
2answers
2k views

Can less invoke vim instead of the default vi when I hit the 'v' key?

I want to launch vim instead of the default vi editor when I hit v in less. Are there any settings I can modify to allow me to do this?
6
votes
2answers
1k views

Fixing CTRL-* in vim under GNU screen

When running vim under GNU screen, I'm finding that combinations of CTRL with the arrow and Pg* keys don't work as expected. I'm using the Ubuntu 10.10 vim-gnome package. On a different machine, ...
3
votes
2answers
1k views

vim - but with scrolling, clickable text, and copy-paste

I like vim. I think touching mice is dirty. But sometimes when my hand is already on a mouse, it sure would be nice to be able to scroll the text or click a location in the text and have the cursor ...
8
votes
7answers
1k views

Open a file given by the result of a command in vim

I find myself doing the following almost every day Run a find (find -name somefile.txt) Open the result in vim The problem is I have to copy and paste the result of the find into the vim command. ...
11
votes
3answers
3k views

How to enter a tab character in vim with SuperTab plugin enabled?

How to enter a tab character in vim with SuperTab plugin enabled?
8
votes
1answer
343 views

Is there a way to move by screen lines in vim?

When editing files in vim, it is a small annoyance that when I move lines with j and k, it moves by file lines, rather than screen lines like other editors. With my own files, I can deal with this by ...
8
votes
1answer
3k views

How can I disable bells/visualbells in vim?

How can I disable bells/visualbells in vim? I've tried: set noeb set novb .. but nothing has changed afaik. Just to be clear, I'm referring to the visual bell I get in vim when I do something ...
7
votes
2answers
2k views

Turning off splitting lines in vim

One of the most annoying features of vim is splitting lines. For some reasons someone found it would be good to split lines even in whitespace sensitive formats. For example changing: echo ...
5
votes
2answers
636 views

viewing info documentation with vim

I'm trying to use the ManPageView addon to view info documentation within vim. Although I find ManPageView very useful for, well, viewing manpages, its info-reading functionality doesn't seem to work ...
5
votes
1answer
416 views

As we call `#!/bin/perl` 'shebang', what we call `-*- perl -*-`?

The first line of a script may be in format of #! interpreter, so the shell will execute the script using the specific interpreter. This is so called shebang or shbang. Similarly, there can be some ...
17
votes
3answers
6k views

Buffers or tabs in vim? What are advantages/disadvantages of each approach?

I'm used to modeless editors. Only the past year I've been using vim/gvim, which has a modal approach. I'm used to tabs in all editors, since before vim all of them are used to it. In gvim, you don't ...
4
votes
2answers
1k views

cursor position after pasting in vi / vim

One thing that has always bothered me in vi / vim: If I "yank" (a.k.a. "copy") some text, then move to another place in the file and do a "paste", my cursor remains at the beginning of the text I ...
12
votes
2answers
6k views

Best way to upgrade vim/gvim to 7.3 in Ubuntu 10.04?

I have to use Ubuntu 10.04 at work, and cant upgrade it. I'm using Vim/gVim 7.2. I want to upgrade it to 7.3 (with Python and Ruby extension support). Which is the best way? Add an entry in ...
2
votes
2answers
391 views

lookbehind and using it with grep in Vi?

Trying to get into Vi (not Vim), after learning Vim. Vim has a lookabehind like /\(Not this\)\@<!$, how to do it in Vi? If I want to search recurvively down directory in Vim, I could do :vimgrep ...
9
votes
2answers
387 views

How do I modify the ci command in vim

Just like "ci(" changes everything between parentheses, I want "ci$" to change everything between dollar signs (for editing LaTeX.) Is this possible?
8
votes
2answers
331 views

Vim command for inserting a character

I'm looking for the opposite of x. I want to insert just one character and stay in command mode.
7
votes
3answers
456 views

Block motion for any bracket type?

If I want to, say delete a block, I can use text object motions. I.e if my text looks like this: (let [a 1 b {:x 3 :y 4}] a) And the cursor is for example on character 3. If I type diB ...