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

learn more… | top users | synonyms

5
votes
3answers
1k views

E763 with vim and spell checker

I want to add germand spell checking to vim. So I set :set spl=de_de spell then there is a dialogue, where I can create a directory called .vim/spell. And then there is another question where I can ...
5
votes
3answers
2k views

In vim, search backwards for matching braces/parens

As most of you probably know, you can use % to search forwards on the line to find the next paired brace/bracket/paren and move to its matched partner: |a|rray[index] = value; " |e| is the cursor; ...
5
votes
2answers
26 views

Color coding html color sequeces in vim

It it possible to setup syntax highlighting in vim so that a html color sequence is colored in that color, e.g. #FF0000 would show up as red. I'd also be ok with it underlining the text that color ...
5
votes
2answers
432 views

Carriage return vs newline in vim

In vim, when I opened a file, I wanted to add two empty lines at the end of each current line. I used the following switch: %s/$/\n\n/ Apparently, this does not work, but what does work is: ...
5
votes
2answers
172 views

How to consistently start Vim's command line to make a mapping work in any mode?

I try to normalize access to Vim's command line mode from any other mode in order to simplify my actual mappings. For example to make the <f6> key work from anywhere I define the following ...
5
votes
1answer
641 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 ...
5
votes
1answer
72 views

Copy/paste across vim without X

In vim, "+p pastes from the system clipboard. However, when working remotely over SSH on a non-GUI box, this is not available. Is it possible to implement copy/paste in this environment? Merely ...
5
votes
2answers
128 views

Make vimdiff display different lines as different lines (not partially different)

vimdiff has an annoying habit of displaying two almost-completely-different lines as the same partially-different line just because they share a character in common at the beginning or end. For ...
5
votes
2answers
838 views

How can I disable terminal resizing

Vim scripts sometimes resize the whole shell (in my case the Taglist plugin). I don't want this behavior, which is possible with the shell command resize, too. Is there a way to suppress the whole ...
5
votes
1answer
117 views

Vim syntax highlight certain lines

I have php files well any file type in general that I would like vim to highlight here docs sections using a different syntax highlighting. <?php echo <<<HTMLDOC <h1> I am ...
5
votes
0answers
158 views

Bash inside Vim not working properly

In MacVim I'm using Conque to run bash commands inside Vim. I have a problem with the text navigation while using Conque. If I'm at the end of a line of text and press down Alt← I skip a word to the ...
5
votes
3answers
421 views

Search and replace next n words in vi [duplicate]

Possible Duplicate: Vim :s replace first N < g occurrences on a line In vi, how do I search and replace a word's first n occurrences with a word, say "hello", and the next m occurrences ...
4
votes
6answers
2k 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 ...
4
votes
3answers
3k views

vi/vim, how can I write out a number of lines to a new file

I have a bunch of lines that I want to write out to a different file. How can I do that?
4
votes
3answers
318 views

Any way to provide a separate vimrc file just for 1 session

I would like to know, if there is a way in vim/vi to provide a different vimrc file. I am looking at managing 2 different vimrc files. For the contents I checkout/checkin in version control I want to ...
4
votes
2answers
340 views

Sudoedit Vim force write (update) without quit

I'm doing some scripting with Vim and I've just started using sudoedit. Problem is, when I :w it writes to the temp file, so any testing of the script can't happen unless I quit the editor. How can ...
4
votes
3answers
161 views

What's the syntax for selecting a range of lines in Vim?

What's the syntax for selecting a range of lines? I want to run a command over lines 1405 until 1700. And one from 1405 until the end of file, without wanting to look up that number. Update: Is it ...
4
votes
3answers
901 views

Vim unnamed register + or *

Im using Vim 7.3 in Ubuntu and I'm having a little problem copying to the system clipboard with the following command "+y but I'm getting the following error: E354: Invalid register name: '+' In my ...
4
votes
3answers
738 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 ...
4
votes
3answers
189 views

What is difference between w and W in escape mode of vim?

I am looking at the vim help quickref commands for moving cursor. Following lines confuse me because I find both of them working same. Could some one elaborate me difference with an example. N w ...
4
votes
3answers
675 views

`grep -l .. | xargs vim` generates a warning, why?

If I run a command like grep -rl test . | xargs vim I get a warning "Vim: Warning: Input is not from a terminal." But I am still able to edit the files. Why the warning?
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 ...
4
votes
4answers
14k views

“Swap file xxx already exists” when editing apache configuration file in vim?

Using vim I keep getting a message saying "Swap file xxx already exists" when I'm editing an apache config. However, I don't see it in the working directory on in tmp. How do I delete this?
4
votes
4answers
997 views

vim search numbers containing specific number of digits

I need to find specific length numbers in a big document. I tried to use regex for this. For example, If I need to search for numbers with exactly 2 digits, I use /d/d (i.e. /d twice followed by a ...
4
votes
1answer
173 views

Different vim colorscheme depending on mode

I'm often doing the same mistake in vim: I forget whether I'm in insert or command mode, then I type in, I get random commands or I modify/delete code, and I have to undo. I do this mistake really ...
4
votes
1answer
4k views

Replace using VIM, reuse part of the search pattern

I am working with VIm and trying to set up a search and replace command to do some replacements where I can re-use the regular expression that is part of my search string. A simple example would be a ...
4
votes
1answer
223 views

How to store Vim tabstop settings in the file?

I need different tab widths for different files when using Vim. Is there a way to store this information in the file, and let Vim apply the setting automatically?
4
votes
2answers
99 views

How can I use caps lock to change language in VIM

Can I use capslock for changing languages in VIM instead of Ctrl + 6 in case of "keymap=russian-jcukenwin"? How can I do it? Maybe something like mapping it in the $VIMRC file? How can I map ...
4
votes
2answers
287 views

echo a customized message with VIM editor

How can I deltect if there is a file modification in VIM upon exiting (:q)? If there is a file modification Vim echos E37: No write since last change (add ! to override) I want to override this ...
4
votes
2answers
2k views

Make sed ask for confirmation before each replacement?

Is there a way to make sed ask me for confirmation before each replace? Something similar to 'c' when using replace inside vim. Does sed do this at all?
4
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 ...
4
votes
1answer
195 views

Idle terminal safe character

I'm using iTerm2 on a Mac to do Linux work. In order to avoid losing terminal connections, I turned on "When idle, sent Ascii code". The default is 0. This works like a charm to keep connections ...
4
votes
2answers
226 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 ...
4
votes
3answers
592 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 ...
4
votes
3answers
885 views

Can't open syntax.vim error when using vimrc

When I try to open my .bashrc file. then it shows these lines: Errordetected while processing /etc/vimrc: line 45: E848: Can't open file /usr/share/vim/vim70/syntax/syntax.vim Press ENTER or type ...
4
votes
1answer
767 views

How to automatically refresh Vim on buffer/window focus?

I often use Control+L to redraw the screen in Vim. In particular, when I come out of sleep or change monitor configurations I often find that Vim needs to be redrawn. I thought it might be simpler to ...
4
votes
2answers
830 views

Modeless vs modal editors

I just started learning Linux and all my previous experience of programming has been using the Windows platform. I came across Vim editor and read that it is modal editor unlike notepad which is ...
4
votes
1answer
236 views

Switching between split buffers in vim

recently starting trying to use VIM as my full-time text editor since I spent a lot of time SSH'ed anyways. Recently installed NERDTree so I can quickly swap between files in a project. Easy question ...
4
votes
2answers
224 views

Indenting multiple files

I want to indent multiple files which are poorly indented and indent them properly as would vim do when I type gg=G. Is there someway to enter the = command or its alias in the command mode? i.e ...
4
votes
1answer
282 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 ...
4
votes
3answers
3k views

Transaction check error in installing vim?

I recently updated my fedora to 20 and wanted to install vim.but running sudo yum install vim returned this error: Transaction check error: file /usr/share/man/man1/vim.1.gz from install of ...
4
votes
1answer
125 views

Customised vimrc for subfolders and projects

I use vim in many different contexts ... actually, probably most people do: There is the editing of configuration files, programming, documenting, email and so forth. I very frequently found myself ...
4
votes
1answer
46 views

How do I highlight commas not followed by a space in vim?

I've gotten into the habit of not appending spaces after commas in lists, when coding. To break this habit, I thought I'd get vim to highlight any comma (,) that is not followed by a space. So I've ...
4
votes
1answer
116 views

Right-align comments in vim

I'm writing C code using vim and are searching for a possibility to right-align my comments so that they all end at col 80. To give a short example: int a = 80; /* initialize a */ int b = 7; /* ...
4
votes
1answer
119 views

Can I access X11's clipboard from tty1-6?

Sometimes, when I'm running on battery and don't need a window manager, I'll log into tty1, fire up fbterm and Vim and work. Later, if I need the window manager, I'll use the log in GUI but switch ...
4
votes
2answers
382 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. ...
4
votes
4answers
265 views

Vim: copy, then paste more than once

I use the highlight mode in vim to copy a few characters. I then want to paste more than once. My current technique does not work well. Sample text: Linux Solaris Irix HP-UX Suppose I want to copy ...
4
votes
1answer
2k views

Why is vim creating files with DOS line endings?

I have set fileformat=unix in my .vimrc, and yet if I create a file in vim (running in Cygwin) it persists in creating DOS files, and I have to run the little cotton-pickers through dos2unix to ...
4
votes
1answer
395 views

Repeat the nth last command in vim

I've noticed vim can be pretty intuitive, but I'm having trouble finding a way to repeat the second-to-last command (or third-to-last, fourth-to-last, etc.). By typing . in normal mode it will repeat ...
4
votes
1answer
165 views

How does this vim command work `:g/#/+1t.`

I was playing vimgolf (very addictive by the way) and I can't understand one of the solutions to this challenge http://vimgolf.com/challenges/4d1a34ccfa85f32065000004 The challenge is to convert this ...