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

learn more… | top users | synonyms

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 ...
5
votes
3answers
418 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
444 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 ...
6
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
304 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
774 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
856 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
185 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
209 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
8k 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
102 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
269 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 ...
38
votes
8answers
22k 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 ...
2
votes
3answers
967 views

Vim shortcuts in insert mode

When I'm entering some text in vim, sometimes I need to jump to some other place and enter more text. I know there are some shortcuts with ctrl key to simplify the movement. What are the most useful ...
2
votes
1answer
422 views

Expand regex on multiple lines in Vim

I am working on removing comments from a C source file. Let's focus on multiline comments /* ... */ and ignore the inline ones (//) The following command seems to work with (solaris) sed: ...
6
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 ...
7
votes
1answer
388 views

Case-preserving search and replace in vim?

In vim, I know I can search with or without case sensitivity. But if I want to search for a string in either upper or lower case, and replace it with a replacement of the same case, is that possible ...
1
vote
1answer
139 views

File open in tabs automatically

I want to set up vim so that it opens automatically in tab and not in buffers. I know that I could use alias gvim='gvim -p' or some such shell mapping but I am wondering if there is a way to do that ...
4
votes
1answer
164 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 ...
10
votes
4answers
1k views

How can I paste (overwriting) with vim?

In vim I use yy and p all the time to yank and paste lines. However, if I want to replace one line multiple places in the file, I can't use yy p dd p because the dd deletes the line to the clipboard ...
2
votes
2answers
283 views

Tab spacing in VIM

I want to change tab key spacing to 4 spaces in VIM editor on CVS server. I know the :set tabstop=4 command is used for that but it does not have a permanent effect. After restarting VIM it changes ...
2
votes
1answer
235 views

Vim: mouse support lost after using netrw in xterm

Every time I access the filesystem using: :tabe dirname (e.g.: :tabe .) :vsp dirname :sp dirname in order to open some file while editing another one, I lose the mouse support inside the Vim ...
4
votes
3answers
892 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
2answers
310 views

vim horizontal line count

Using set number you can turn on vertical line count. Is there also a command to turn on horizontal line count? I hate talking my hands away from typing and would like to be able to quickly address ...
5
votes
2answers
263 views

Provide user name when using vim with scp

I was reading about SSH here http://blogs.perl.org/users/smylers/2011/08/ssh-productivity-tips.html and found that you can use vim to directly modify a file on a remote server that you can ssh into. ...
5
votes
2answers
3k views

Why can't vim find syntax.vim on my fresh Ubuntu installation?

I'm trying to make some basic customizations to vim. All I want is some syntax highlighting, etc. Basically, not just plain text. My .vimrc file consists of 7 lines: backspace=2 syntax on filetype ...
2
votes
2answers
1k views

sv_SE.UTF-8 Problems with Bash and VIM in iTerm2

Two specific issues, despite me running iconv -f iso-8859-15 on my old files when converting from sv_SE.iso8859-15 to sv_SE.utf-8 I still get distorted characters. And I believe it's because of Vim ...
2
votes
1answer
637 views

Vim shared copy register

When working with Vim I often work from multiple monitors and multiple split terminals so I have multiple instances of VIM running at all time. Is there a way to have a persistent shared register that ...
4
votes
1answer
121 views

How to write any Unicode Key without Pre-programmed key for it in kbd?

I am trying to find some Unix tool to input any Unicode key. I am fine with X application or console but I use Vi/m and it may have this property. For example, suppose I want to input key "U+0303" or ...
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?
3
votes
2answers
188 views

Open up many files in panes at once

When I need to edit multiple files, it's really a pain to have to open them one by one. Is there a way to open multiple files in VIM from the commandline?
2
votes
2answers
729 views

How to Display Hidden Characters While Typing?

How can I configure vim to display hidden characters like tabs or spaces ONLY while those characters are typed? I do not want tabs and/or space replaced with special characters like ">" or "_" when ...
2
votes
1answer
60 views

How to Re-Create Missing Vim Directory?

The /etc/vim directory and the symlinks from /usr/share/vim to it are missing. Does anyone know how to re-create the directory and links?
3
votes
2answers
1k views

(G)VIM uses a different $PATH than my system

Because Ubuntu provides no up-to-date packages for TeXLive, I installed it manually. However, some programs need TeXLive as dependency. So what I did is I installed the TeXLive package from the Ubuntu ...
4
votes
2answers
1k views

How to install light-weight vim and to be able to efficiently load files into one instance vim?

On my laptop with Ubuntu I'm able to have just one instance of vim, launched with vim --servername VIM After this I'm able to open files from console with vim --remote-silent filename I use ...
1
vote
2answers
75 views

VIM: Create a function to generate several lines of buffer

I have about ninety configuration files that I need to add an almost identical block of additional code to, with only two instances of a single word differing each time. I would very much like to ...
3
votes
5answers
1k views

vi - how to join differents specific lines

I'm looking for a solution about a "paste" problem on vi/vim . How to join specific lines in a text file? I have a file like this: 15/10/2011 Revolution day 16/10/2011 About Rome - differents ...
5
votes
3answers
274 views

vim regex not need \ to escape

In Vim is there an option to write regexs in the same style as Awk for example/sp\{0,\}/ Would be /sp{0,}/
21
votes
2answers
16k 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 ...
9
votes
1answer
814 views

Why am I getting 'Name collision between …' errors and how can I fix them?

Every time I try to launch vim or emacs or even top (I think it's actually any command that uses ncurses) in a unix terminal (on a cluster computer over ssh), I get a a continuous stream of 'Name ...
2
votes
1answer
265 views

How to open a file in the last closed position in VI

I want to open a file which is closed in line xxx. So I can easily continue editing
7
votes
1answer
5k views

Switch VI to use backspace key instead of Control+H for backspace?

I'm on Solaris 10 and by default vi version SVR4.0, Solaris 2.5.0 is installed. The system was set up so that when I ssh to it Control+H does backspace, and backspace outputs ^? I added stty erase ...
4
votes
1answer
404 views

How to run gVim in a single instance

I want it in such a way that on double clicking an already opened file, or a new file, gVim uses the same window. From this question asked previously on Stackoverflow I figured out how to do this by ...
11
votes
3answers
3k views

ESC key causes a small delay in terminal due to its Alt+ behavior

My terminal setup is gnome-terminal + tmux + zsh with vi bindings. In applications like vim or even in the zsh's command line vi editing mode, I need to frequently hit the ESC key but there is a ...
3
votes
5answers
3k views

How can I check what version of the VI editor I have?

How can I check what version of the vi editor I have? What's the best way to upgrade it or install vim on Solaris?
2
votes
1answer
1k views

Install Gvim after vim

I would like to run vim via X11 (over SSH). Vim comes pre-installed on my NAS (running Debian), however the GUI is not. When I run vim -g, I get this error: E25: GUI cannot be used: Not enabled at ...
6
votes
4answers
931 views

Block editing *live* in Emacs or Vim

jEdit supports block editing, but Emacs and Vim seem to have some serious usability issues on the same subject. If someone could fill in the unknowns here it would be much more bearable to use either ...
6
votes
2answers
216 views

How to write a column of consecutive integers in Vim over existing text?

For example, imagine I had the following text: / apple / orange / banana / bread How could I efficiently add consecutive integers in a column to make? /1 apple /2 orange /3 banana /4 bread Note ...