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

learn more… | top users | synonyms

1
vote
1answer
325 views

How to set keycodes manually in vim?

Sometimes when I fire up vim, my Insert key doesn't work (need to use i) and my arrows don't work (they give me letters instead). I'm guessing this has to do with my keys not being mapped correctly. ...
2
votes
1answer
328 views

vim script: how to change “put =” to an append?

I'm trying to hack the c-vim plugin because I don't like the way it inserts comments. I want this: /* comment */ but it gives me this: /* comment */ I'm sure it has its reasons, but I don't ...
2
votes
1answer
124 views

Vim Highlight only the characters, which produce comments

I am trying to achieve the following. If I have a file, e.g. a tex document and I want to have the following with commenting characters (% symbols) highlighted: % Some text and end of the ...
4
votes
2answers
2k views

Using vim to view the contents of a directory file

As I understand, in Linux directories are mostly normal files w/ some special handling (e.g. 'rm' a file is ok; 'rm' a dir will complain w/o -r). When I execute the following bash commands: mkdir ...
2
votes
1answer
157 views

Why does Vim have different cursor positions for different modes?

Why does vim have different cursor positions for the different modes? First, in insert mode, the cursor is between characters (like every other editor), second, in command mode, the cursor is under a ...
3
votes
1answer
1k views

vim is too slow when saving files

I run vi under Linux CentOS 5.3. Each time I exit from a file, I have to wait several seconds before vi saves the file. The same thing happens with vim. I ran this command: strace -odetails -ff -f ...
9
votes
2answers
1k views

Select code block in vim

Given a code like this: 588 while ($linecounter > 0) { 589 $token = " "; 590 while ($token != PHP_EOL) { 591 if (fseek($handle, $pos, SEEK_END) == ...
4
votes
2answers
223 views

Problem : how can I copy/paste this in vim?

I'm working with the vim editor and I found y,yw respectively to copy a line and a word but how can I do the following task in vim? www.pack.google.com From this line how can I copy and paste ...
4
votes
1answer
142 views

Rewrite a Vim function to a one-line map

This works: nmap <silent> <S-t> :call InventTab()<CR> function InventTab() set expandtab! if &expandtab retab echo 'spaces' else retab! ...
5
votes
1answer
256 views

Why doesn't vim ask for password when reopenning an encrypted file?

If I run Vim and then open an encrypted file it asks for the encryption password. If I close the window where the file was opened (without closing vim) and then reopen the file, the password prompt is ...
3
votes
2answers
143 views

The right way to wrap block of lines in custom text in vim

I would like to be able to select several lines using vim when editing an HTML file, then enter some hotkey and get these lines wrapped in a django comment block. For example, I have: one line ...
1
vote
1answer
440 views

How to change vim auto-indent behavior?

By default vim aligns lines inside LI tags on the same position as the position of LI tag, but I want the contents of LI to have deeper indentation. Current behaviour: <LI> first line second ...
2
votes
2answers
109 views

Vim markers and macros

Is there a way to make a macro operate up to a marker? I know if I do 5@a my macro will operate on 5 lines. Example: set marker with `mc` record a macro with `qa` ... now what? Obviously 'c@a just ...
3
votes
3answers
370 views

Open another file with split windows, and switch between them

If I open vim with: $ vim -o a.ext b.ext I get a window that looks like this +----------------------+ | a | | | | a.ext ---------------+ | b ...
6
votes
4answers
970 views

Indent several lines with VIM?

For eample, I'm editing this code: <html> <body> <script> var a = 10; a += 100; </script> </body> </html> now I need to indent the script line: ...
6
votes
1answer
152 views

making vim fold also hide newline after function

How can one make vim's fold function - when using foldmethod=syntax - also hide one newline after each function, if-else and struct (using Go).
9
votes
2answers
332 views

Vim, context-sensitive comment/uncomment behavior

I edit a lot of PHP code with Vim, and I've run into a snag with some macros in my .vimrc. I currently use these two macros to comment/uncomment in C-style "c-style (//) comment (press the [.] key) ...
2
votes
4answers
690 views

Turn NumLock on on startup?

I usually edit in Vim,and when pressing +, I'd rather move my hand to the right part of the keyboard where + resides rather than doing shift + =. But when NumLock is not on, in Vim it just opens a ...
7
votes
2answers
231 views

How do I get just the user-manual for Vim

To get the vim user-manual I am doing vi test and then, once the file is opened, I do :help user-manual This opens up a split window, which makes reading manual inconvenient to read. How do I ...
2
votes
1answer
360 views

Fall-back for $VIM is invalid

I am working directly on a dev server and want to build my own vim, for my purposes, not for all system users. The build scenario is: hg clone https://vim.googlecode.com/hg/ vim cd vim/src ...
1
vote
3answers
275 views

vim/emacs plugin to view recursive grep search search results?

Suppose I have a file formatted like this: file1:123 file2:4444 some/other/file:2233 This represents the search results from a grep (i.e. file:line-number). I'd like to have a vim plugin which ...
2
votes
2answers
716 views

ZSH tab completion: only complete files and not binaries

Is it possible to make a custom zsh completion file,so when hitting tab for filenames it avoids completing the binaries? For example,I have 2 files , myprogram.c and myprogram,the binary,is it ...
6
votes
5answers
2k views

vim editing/switching between multiple files efficiently in large directory structures

I am by no means a vim power user, I am just beginning to grasp the advanced motions and commands with vim. But there's one drawback that I can't seem to get around. I grew up with graphical ...
3
votes
2answers
4k views

How to map ALT key in .vimrc?

In order to be able add blank lines without going into insertion mode, I'm trying to map ALT-o and ALT-O to o<ESC> and o<ESC> I've tried the following in my .vimrc map <M-o> ...
6
votes
5answers
3k views

vi command for adding blank line?

In vi, I can use o or O to add a blank line and go into insertion mode. But what if I want to stay in command mode, is there a command for this? In googling, I'm seeing suggestions to add stuff to my ...
8
votes
4answers
1k views

Why would vim return non-zero exit code if I exit immediately after opening?

I'm running into a bit of a strange problem w/ vim on Snow Leopard: I get a non-zero exit code from simply running vim and then quitting. $ vim # exit immediately using :q $ echo $? 1 However, if I ...
2
votes
2answers
368 views

Vim keybinding to delete up to (but not including) the next period

I've noticed a common idiom in my editing is a desire to delete everything up to, but not including, the next period. After a bit of researching online, I found the following command will work (I ...
3
votes
1answer
496 views

Quit VIM is slow, usually 2 seconds, it shows

On quit, vim shows that: ".netrwhist" [Not edited] --No lines in buffer-- This process usually takes 2s. How to turn this thing off? --- Update --- I noticed that netrw is installed as ...
0
votes
1answer
499 views

Documentation for vifm?

vifm looks like a good file manager, but it lacks documentation. Is there a manual or tips on how to use it? I'm looking for information on copying/moving a dir, creating a new empty file, editing a ...
11
votes
4answers
353 views

Is there a vim shortcut for <name of current file>?

In vim, if I'm working on a Python script, I will commonly type: :! python this_script.py to execute the script. Is there a shortcut for the name of the current file? If not, can I easily make one? ...
4
votes
2answers
214 views

Vim - buffer names in the cmd line area

When I edit files with vim there is always this in the cmd line area,under the status line,all buffers' names(image : ) Is there any way I can remove it?
1
vote
3answers
1k views

Is it possible to execute a VIM script in a non-interactive mode?

The Gnats bug tracker has a command (edit-pr) that opens a ticket in $EDITOR. My $EDITOR is VIM, and when this command opens the ticket in $EDITOR, I'd like to automatically perform some scripted ...
4
votes
2answers
209 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 ...
10
votes
4answers
8k views

How to select/delete until end of file in vim/gvim?

Accidentally I managed to copy-paste a paragraph in vim a zillion times. How do I select and then delete the text from my current position to the end of file? In Windows, this would be ...
3
votes
2answers
1k views

How to copy from one vim instance to another using registers

How can I select the + register? I have problems following the instructions below to copy/paste text from vim to another vim: In the vim, highlight, select + register, and yank (save) to it: Shift-v ...
2
votes
1answer
108 views

Script for opening corresponding pdfs for bibtex keys in Vim

Context I currently write research articles in LaTeX using Vim. I have bibtex keys in my articles like \cite{smith2000sometopic} and I have corresponding pdf versions of most articles in a subfolder ...
6
votes
1answer
144 views

Sending commands to dbx from Vim

Using this information, I've been able to debug code using dbx and display the code from within Vim. What would be really cool is if I could send commands (step, next, print, stop in ... etc) to dbx ...
1
vote
2answers
124 views

How to display the server time inside Vim

I want to know how to display the server time inside the Vim editor, if possible.
7
votes
2answers
596 views

vim spell checker?

Is there a way to spell check a file using vim?
8
votes
4answers
1k 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?
25
votes
8answers
16k 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
687 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 ...
3
votes
1answer
337 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
202 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
563 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
814 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: ...
6
votes
6answers
4k 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. ...
24
votes
4answers
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
6k 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 ...
33
votes
4answers
2k 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 ...