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

learn more… | top users | synonyms

1
vote
2answers
143 views

Saving files on lost focus in Vim

I have been trying to setup the shell version of vim to save any changed files when the shell window loses focus. Following these instructions does not work. Even though I am using OS X, I figure ...
3
votes
3answers
2k views

Problem with vim when logged in as root

When I login as root or edit a file by sudo mode all of the options in my /etc/vimrc are not working (e.g. highlight line-number etc.)
2
votes
1answer
304 views

Vim - Bind a key to a bash command

In VIM, is there a way to bind a key to a shell command? For example when F3 is pressed git commit -a -m "test" should be executed.
0
votes
1answer
39 views

Make gVim use last compiled version of vim

I've compiled the latest version of vim with some options. Is there a way to make gVim use the same vim as in the console ?
2
votes
0answers
172 views

Vim - Cursorline turns on after saving a remote file

Using vim scp://.... I open a remote file. cursorline is not shown until I save the file(:w). When I type :w and enter password, cursorline appears.If I type :set nocursorline it disappears but again ...
13
votes
3answers
2k views

How different is Elvis from Vim?

I've been using Slackware for a while now, which ships with Elvis as its default editor. Most other Linux distributions seem to ship with Vim, instead of Elvis. Having gotten quite used to Elvis, ...
3
votes
6answers
722 views

Add consecutive numbers succintly and elegantly to index lines

I usually do this $ wc questions 33 36 3105 questions $ seq 1 33 > nums $ paste nums questions 1 Content 2 ... . . 33 End Content but I feel there could be faster way to do ...
5
votes
2answers
703 views

Can I make Tmux tell Vim when its pane loses focus?

I use Vim and Bash side-by-side in Tmux. I have Vim configured to autosave files as I switch between them, but I'd really like it to autosave when I switch to the Bash pane. Is there a way to get ...
8
votes
3answers
2k views

How to make a symbolic link to /usr/bin/vim but with start-up parameters?

After I make&make install vim from source, I found many symbolic links of vim in /usr/local/bin, such as evim, rvim, view... The vim(1) man page said that "rvim" is equivalent to "vim -Z" and so ...
1
vote
2answers
592 views

How can I unset non standard vim options?

On a hosted system I logged in via SSH and edited a file with vim. Usually once I'm in insert mode I can just paste from my local clipboard into the ssh window and VIM accepts it fine, but for some ...
1
vote
1answer
97 views

Is “temp” a reserved system name?

I was doing homework on a remote server, and I realized that I had my header and cpp files swapped. So, I wanted to change the names. I began by renaming my header file 'temp'. Then, weird things ...
4
votes
4answers
15k 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?
2
votes
4answers
250 views

xsel < /tmp/xselection not working in script

I'm trying to use the following script: #!/usr/bin/env bash # Edit xselection in gvim xsel > /tmp/xselection gvim /tmp/xselection xsel < /tmp/xselection But the final line does not seem to be ...
4
votes
1answer
765 views

How can I search for and highlight multiple strings in VIM?

In VIM, how can I search for multiple strings and have a different color highlight for each match?
6
votes
5answers
790 views

Terminal and Vim

I open a terminal then I open Vim. Then I work on my source code, but unfortunately I click on the close button of the terminal title bar and my work is lost. Is it possible to configure Vim such that ...
8
votes
5answers
3k views

What is `^M` and how do I get rid of it?

When I open the file in vim I am seeing strange ^M characters. Unfortunately, the world's favorite search engine does not do well with special characters in queries, so I'm asking here: What is ...
9
votes
5answers
3k views

vim: replace all character till end of line

Maybe I am being daft but can you replace all the characters from where the cursor is to the end of line by one command? Then use . to do the same replace on the next line and so on.
13
votes
2answers
9k views

What does the noeol indicator at the bottom of a vim edit session mean?

I open a file using vim in ubuntu, and this is displayed at the bottom of the screen. "file.py" [noeol] 553L, 16620C What does noeol indicate ?
0
votes
2answers
392 views

Storing Abbreviations in Vim

I frequently use :ab to save typing time during coding. For e.g. :ab mat matrix to replace mat by matrix every time I type mat. Is there any way of storing and loading the abbreviations I create for ...
0
votes
1answer
400 views

Remapping keys in vim's “directory view”

The "Netrw Directory Listing" you get by opening a directory in vim (e.g. :e .) seems to use a different set of keybindings than plain vim for navigation I have my hjkl keys remapped thus: noremap d ...
1
vote
1answer
102 views

VIM - how to minimize tabindent on hilighted text

Right now, my VIM editor tab indent has some unusual behaviour. When I am in insert mode and press tab, the cursor indents about 3 spaces instead of a whole tab indent. I like this. When I ...
1
vote
2answers
1k views

Script to create files in a template

I just wrote a function in my ~/.bashrc that will let me create a folder for a new website with one command. The function looks like this: function newsite() { mkcd "$*" # mkdir and cd into it ...
3
votes
2answers
819 views

Avoid reformatting bullet lists with formatoptions+=a

I am using Vim with formatoptions +=a as described in Vim: word wrap for documents to format lines automatically while I write documents, expecially Markdown documents. My problem is that Vim wants ...
5
votes
2answers
331 views

Make vim / curl recognize https:// links

I recently noticed vim/vimdiff can open links (using curl, it seems), which is an awesome feature. I wanted to use it today, like this: vimdiff deps ...
11
votes
2answers
1k views

Spell check comments in vim

I'm a C/C++ professional programmer who makes lots of spelling mistakes in comments. I want to configure vim such that the spell-checker only looks for misspelled words within comments. If necessary ...
1
vote
2answers
88 views

Graphical issues in vim

Not sure if this is the best place to ask this but does anyone know why I'm seeing those purple-ish bars in my vim? My vimrc http://dpaste.com/698999/ Also, I'm using Lion OSX
2
votes
1answer
127 views

Scroll % in Vim cmd line?

I apologize for the n00bish question, however it's one of those where the key terms are too generic to find an answer very easily. Basically on all my Linux installations, opening any file in Vim ...
9
votes
3answers
6k views

How to move to last character of the file in vim?

File: i am someone1. i am someone2. i am someone3 ~ ~ Documentation says G takes me end of the file, but it only takes me to the beginning of last line. I want to be able to come to last character ...
6
votes
1answer
752 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 ...
15
votes
2answers
6k views

What is the difference between vi and vim?

As far as I know vi is more commonly found on out-of-the-box unix systems while vim often has to be installed. Also vim stands for vi improved, but improved how? What are the main differences?
18
votes
6answers
4k views

Advantages of using set -o vi

I have seen many developers using this command to set the option to vi. I never understood the real use of this? When using bash commands, what help does switching to vi provide?
2
votes
1answer
526 views

How to add additional Gnome-Shell and Unity workspace navigation shortcuts

I am very familiar with (and love) the workspace switching in Gnome-Shell and Unity (using Ctrl+Alt+[Up/Down/Right/Left]), but being a vim fan, it would also be great if I could add an additional ...
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; ...
2
votes
1answer
72 views

!fmt for current line only

When I want to format part of text with fmt in vim I usually select parts of interesting lines in Visual Mode, with: Ctrl+V Arrows, and than type !+f+m+t. When there are couple of lines they are ...
4
votes
3answers
162 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 ...
15
votes
4answers
5k 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 ...
5
votes
3answers
468 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 ...
5
votes
1answer
473 views

Conditional search and replace on a line in vim?

Let' say I want to comment and uncomment a line. I know I can :s!^!//! and then :s!^//!! Now what if I want this as an one-liner? Basically, if a line starts with // then remove it, else add ...
7
votes
1answer
1k views

In vim, how to map “command-right” and “command-left” to beginning of line and end of line on mac?

I'm trying to get it to be like default text editing in Mac. I tried map! <D-Left> 0 and map! <D-Right> $ in ~/.vimrc, but of course it didn't work. How can i do this?
6
votes
1answer
323 views

Interactive tree command

Is there any version of tree command that displays file structure as a tree structure, but in a way that I can interactively walk trough? Why do I need it exactly - I am trying to simulate TextMate ...
9
votes
4answers
1k views

Delete whitespace for a set of lines in Vim editor

I have some text like the following in a file: sample text some random text even more random text text with no indent worst indention I need to delete the empty space before each ...
4
votes
2answers
2k views

Vim NERDTree re-size vsplit

I am using the NERDTree plugin for Vim. When using the s: open vsplit command, is it possible to resize the windows so that the file takes up a larger portion of the screen than the directory tree?
2
votes
3answers
926 views

console vim in screen session: remap Ctrl-Shift-Left, Ctrl-Shift-Right to not delete lines

I have my gvim setup so that I can select word-wise with Ctrl-Shift-Right, Ctrl-Shift-Left etc. (yes, I know it's a bad habit, but it works for me..). Unfortunately, these key combinations delete ...
6
votes
1answer
190 views

Why does mapping <esc> cause arrow keys to fail in vim?

When I do inoremap <Esc> <Esc>`^ in vim, the next time I switch to insert mode (after using Esc) the arrow keys fail to move the cursor (they insert letters instead). Why does that ...
1
vote
1answer
4k views

Use configuration file for ftp with auto login enabled upon initial connection

I would like to so the same thing like in SSH where you can save the server in the config file. I would also like to save my username and password, so that it is not prompted each time I connect. I ...
1
vote
1answer
213 views

Vim: VimRepress and Wordpress.com - how to insert code snippets?

I've started using Vim and VimRepress plugin to blog. My blog is on Wordpress.com - so I cannot install plugins etc. A lot of my posts have code snippets in them - and in Markdown syntax, I indent ...
7
votes
4answers
10k views

What causes swap files to be created?

As part of the program I wrote, I constantly read and write data from files. I noticed that as part of doing so, I am inadvertently creating swap .swp files. What do you think is going on? What would ...
2
votes
1answer
104 views

How to limit a search to the current line

VIM newbie here. I'm trying to write a mapping that will let me move around 'common' insertion points in a line when in insert mode. For ex. I have the delimitMate plugin - so typing a opening ...
1
vote
0answers
280 views

how to focus different `regions`(Ctrl-a S) via mouse-click in `screen`?

When I start vim in a screen session, and activate the mouse: :set mouse=a the mouse remains disabled. I cannot switch tabs via mouse click. How can I configure screen so that mouse support in vim ...
39
votes
8answers
25k 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 ...