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

learn more… | top users | synonyms

14
votes
3answers
3k views

How to fix Ctrl + arrows in Vim?

I am using Putty -> Suse box -> vim 7.2 combo for editing and want to remap Ctrl + arrows combo to a particular task. But for some reason, Vim ignores the shortcut and goes into insert mode and ...
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 ...
12
votes
2answers
5k 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 ...
8
votes
2answers
563 views

What is meant by a shell is in “vi” mode or “emacs” mode?

This question follows directly from the answer to one of my previous questions here. I am newbie to unix world and this site has helped a lot to understand some core concepts. In this case I am ...
141
votes
14answers
38k views

What are the pros and cons of Vim and Emacs?

How would you compare these editors? What are the pros and cons of each? [note] This is not meant to be answered by those who "hate one and love another" or those who haven't used both.
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 ...
20
votes
9answers
718 views

How to find out which file is currently opened in vim?

This may sound trivial but, on more than one occasion, I have found myself having forgotten which file in vim I have open (e.g. when I am looking through different log files and such) and the only way ...
5
votes
2answers
689 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 ...
5
votes
3answers
3k views

Vim :s replace first N < g occurrences on a line

In vim, I sometimes have occasion to replace the first few occurrences of a match on a line, but not every one like g would. e.g.: a a a a a to b b b a a I know I could use ...
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?
4
votes
7answers
850 views

Uncommenting multiple lines of code, specified by line numbers, using vi or vim

I have learned from this Stack Overflow question that it is possible to use vi/vim to comment out a specified range of line numbers. For example, suppose I have the following bash script: ...
4
votes
1answer
444 views

Match word containing characters beyond a-zA-Z

To match a word one can use \v(\w+) From the vim help :h \w: \w word character: [0-9A-Za-z_] This works exactly as described in the manual. However, I want to match words that contain ...
33
votes
6answers
17k views

How can I edit multiple files in VIM?

I know I can open multiple files with vim by doing something like vim 2011-12*.log, but how can I switch between files and close the files one at a time? Also, how can I tell the file name of the ...
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 ...
21
votes
2answers
13k views

How can I set VIM's default encoding to UTF-8?

I'd like to contribute to an open source project providing translated strings. One of their requirements is that contributors must use UTF-8 as the encoding for the PO files. I'm using VIM 7.3 on ...
18
votes
6answers
2k views

Using VI keys to edit shell commands in UNIX

I used to have a co-worker who was really good at UNIX. He showed me how to use Vi key bindings to edit my shell commands. He placed the command in a file that ran every time I logged in. Since ...
15
votes
5answers
2k views

How to yank a particular line without moving the cursor in vim?

For example How can I yank and paste Line 4 only to Line 12 without having to move the cursor to Line 4?
18
votes
6answers
5k views

Vi vs vim, or, is there any reason why I would ever want to use vi?

I know a bit about *NIX text editors (currently migrating from nano to vim), and, after looking around a bit on the Unix & Linux SE, have noticed that a fair about of question use vi instead of ...
13
votes
3answers
9k views

Comparing two files in Vim

Is it possible to view two files side-by-side in Vim? If so, how can I set up my editor to do this, and is there a way to diff between the two files within Vim? I am aware of the :next and :prev ...
6
votes
2answers
170 views

tmux, TERM and 256 colours support

Introduction My question arises from the necessity of understanding why I have now (after multiple trials) Terminal and tmux which support 256 colours even with tput colors that tells me they are ...
6
votes
2answers
1k views

Is there a way to place a comment in a file which vim will process in order to set filetype?

For example, if I want to have a file with the name gitconfig (no leading .) be recognised by vim as being of filetype=gitconfig, is there a means of indicating this in a comment or something similar ...
5
votes
3answers
929 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 ...
15
votes
4answers
4k views

How to get vim to work with tmux properly?

I'm trying to figure out how to get vim and tmux play together. My problem is: When I use xterm-256color I get vim to work nicely, but the background doesn't render properly. I fixed this by using ...
6
votes
7answers
840 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. ...
6
votes
1answer
261 views

Application-specific keymapping

In general, I want to make specific keymaps for application, that working only in it and doesn't affect any other app. For example, I already use my Caps key to toggle input language (via xorg.conf), ...
5
votes
1answer
175 views

tmux, Vim and Solarized

Premises Browsing around tmux, Vim and Solarized I can find lots of complains about 256 colours and "user experience". Well, I'm having the opposite "problem", i.e. Vim works well with a full ...
5
votes
2answers
767 views

Is it possible to create and use menus in (terminal-based) vim?

I'm setting up virtualized Linux boxes (as local development servers) for developers at a company that is primarily Windows-based, and some of developers make negative cracks about vim (among other ...
2
votes
1answer
624 views

How to fix the shifted function keys in vim in xterm in gnome-terminal?

When I hit the <s-f2> key to execute my nnoremap <s-f2> :set number! mapping Vim opens its "Insert" mode above (O) and types the 1;2Q string. In order to see the entire terminal key code – ...
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? ...
8
votes
2answers
1k views

why inode value changes when we edit in “vi” editor?

When I edit a file in "vi" editor the inode value of the file is changing. But when edited with cat command the inode value is not changing.
5
votes
1answer
1k views

vim auto indenting even after setting noai option

I am using vim 7.2 from putty terminal. Even if I run set noai it seems vim still trying to indent code. I am copying my code from Notepad++ to vim. following is from Notepad++ and following what I ...
4
votes
1answer
780 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 ...
3
votes
1answer
668 views

Saving with CTRL-s in vim

I have added this line in .vimrc so that pressing control-s saves the current file :nmap <C-s> :w!<cr> :imap <C-s> <esc>:w!<cr> But this is not working. Any ...
3
votes
1answer
244 views

Clipboard over SSH session through VIM

I have a server running SSH, when I edit a file with vim on the remote server, :y+ doesn't work since the VIM binary on that linux system wasn't compiled with X support. (E488: Trailing characters) ...
3
votes
2answers
572 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
4answers
694 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
1answer
2k 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 ...
3
votes
3answers
291 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 ...
3
votes
1answer
79 views

Switching to edit mode in VIM rc?

Still related to the previous question, but switching mode with exe "a" doesn't seem to work, I still have to press the a button manually Here upon opening a newly created a file, a template is in ...
3
votes
1answer
404 views

gvim -p limit of opened tabs?

When I run : gvim -p *.xyz I find that not all files are opened in tabs. It feels, like a kind of tab limit? But ! When I try to open unopened with : :tabnew it is opened next to previous ...
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
2answers
81 views

Command-line editing vim style [duplicate]

I recently discovered terminal's feature, you can set the keys emacs or vi style I prefer the second. so if you do set -o vi You can use k j l h keys to navigate on the command line. And you can ...
2
votes
1answer
179 views

vim and tmux are conflicting. How can I fix this? [duplicate]

I'm having a painful experience with tmux. I'm using solarized in vim but when I run tmux then my vim configuration does not work. It's as if solarized is not configured in my .vimrc. Out of tmux ...
2
votes
3answers
709 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
5k 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 ...
1
vote
1answer
47 views

Jump to the first position of text “<CURSOR>”

I'm using a file template directory for newly created files, autocmd! BufNewFile * silent! 0r ~/.vim/skel/tmpl.%:e Now I want to add another function, that move the cursor to somewhere (defined in ...
1
vote
2answers
341 views

Exiting block insert mode with Ctrl-C

In vim, if you are in block insert mode (Ctrl-V, Shift-I) and exit using Ctrl-C (instead of Esc), it cancels the block edit (and only edits the first row). Why is this? In almost all other contexts, ...
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 ...