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

learn more… | top users | synonyms

6
votes
3answers
4k 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 ...
6
votes
2answers
229 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 ...
6
votes
1answer
101 views

Can I specify the layout of a vsplit command?

When I do the :vsplit command, it always opens the new file on the left side of the screen. Is there a way I can specify I want the new file to open to the right?
6
votes
1answer
272 views

How can I count the number of words in a file whilst editing the file in vim

I know I can use wc for counting characters, words and lines of files at the command line. Is there any way I can can count the number of words while in vim?
6
votes
2answers
246 views

How can I create my own spelling file for vim?

At the moment I'm writing a document where I need to use a lot of acronyms, technical language, and non German words. Now I was wondering if I could create a spelling file (tech_speak) which checks ...
6
votes
1answer
941 views

Replace unicode chars in VIM?

I got some logs from a windows machine, which contains multiple instances of <200e>, I know it's a unicode char, but how can I remove it with s command? I don't know how to input that in the ...
6
votes
3answers
328 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,}/
6
votes
3answers
851 views

How can I open a file in VIM in readonly mode if it already has a swapfile?

When I use the command :e filename to open a file and this file is already opened by another vim instance, I get a prompt asking me if I want to open the file in read-only mode, edit anyway, recover, ...
6
votes
2answers
786 views

Does using ctrl+c instead of esc to exit insert mode break anything in vi?

When using vi, you can exit insert mode with Ctrl + C instead of the more traditional Esc. Are there any situations where it would be undesirable to use for former instead of the latter? Does it break ...
6
votes
1answer
829 views

Only one file name allowed error

Sometimes I forget to do sudo vim and open files to which I don't have write permission. I saw this post and it was really helpful. When I did :w !sudo tee % it asked me for a password and then the ...
6
votes
2answers
372 views

Indent the middle of multiple lines

I often run into situations like this: title : Jekyll Bootstrap tagline: Site Tagline author : name : Name Lastname email : blah@email.test github : username twitter : username feedburner : ...
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 ...
6
votes
1answer
265 views

How to highlight logs with bash coloring on vim?

I have some nicely colored logs from some tools with bash color codes. When I view them through less or similar tools it get color rendered by bash (obviously). However it is pain to watch and edit ...
6
votes
1answer
61 views

Change inside comments with Vim

Is there a way to change inside of a comment with Vim? I know you can change inside brackets and quotes with i] and i". For example, If you are on a quote you can press, ci"my new textESC And ...
6
votes
1answer
1k 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 ...
6
votes
2answers
664 views

viewing info documentation with vim

I'm trying to use the ManPageView addon to view info documentation within vim. Although I find ManPageView very useful for, well, viewing manpages, its info-reading functionality doesn't seem to work ...
6
votes
1answer
315 views

vim: how do I set :match and :2match search results to different colors?

For example, I want something along the lines of: :match search /<div/ guib=Green :match search /<\/div>/ guibf=Blue only that doesn't work.
6
votes
3answers
660 views

Vim: How to get rid of filetype-specific map?

Edit: Working version. I've mapped [[ and ]] to my own functions: nmap <silent> ]] :let &tabstop += 1 <CR> :echo 'tabstop =' &tabstop <CR> nmap <silent> [[ :let ...
6
votes
2answers
420 views

Is there a method for making Google Chrome open textareas in vim?

I used to use Firefox on a daily basis but have switched to Google Chrome, and have been using it for 2+ years now. The one plugin that I miss is this one, It's All Text!. This plugin allowed for the ...
6
votes
2answers
2k views

How to allow Page Up in GNU Screen?

I use Vim to edit text files on Linux. Commonly I connect to remote Linux machines using PuTTY from Windows. I use GNU Screen commonly as well. When using Vim inside Screen I am unable to use the ...
6
votes
1answer
331 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 ...
6
votes
1answer
311 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), ...
6
votes
1answer
2k views

Rename current file in vim

Searching over net shows :f filename would rename the current file in vim. But executing this and later exiting vim, shows the new file with all the contents and also the old file is present with the ...
6
votes
1answer
156 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 ...
6
votes
1answer
290 views

How to change Vim's command type mode programmatically?

Is there a simple way to switch from one command type mode to another without loosing the current command line? In my ~/.vimrc file I remap the <space> and <c-space> character, coming ...
5
votes
9answers
590 views

Replace several strings with other string in several files

I have several text files. All these text files need to undergo a set to editing which can be done in vim. I want to automate this. vim has several commands for replacement. Suppose the text files ...
5
votes
3answers
4k 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?
5
votes
6answers
5k views

How to select complete file in vi, to be pasted in gedit?

I know that doing %y a will yank complete file into register a. However this doesn't help in pasting the file content in another text editor (say gedit). What alternative is there for doing so?
5
votes
3answers
334 views

How to scroll large datafile while keeping header

Suppose I have some large datafile, which overflow the screen in both vertical and horizontal direction. How can I browse this file, while the header-lines stay on the screen? For the moment, I am ...
5
votes
3answers
1k 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 ...
5
votes
2answers
245 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 ...
5
votes
3answers
3k views

Why does my vim-7.3 compile fail to include clientserver?

I am trying to compile vim-7.3 will all features enabled. I ran configure with $ ./configure --with-features=huge --enable-gui --enable-cscope $ make ; make install When I check the version, it ...
5
votes
3answers
1k 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 ...
5
votes
2answers
524 views

Why does Vi have multiple modes?

Why does Vi have multiple modes? I'm not interested in the functions of the modes unless that was a reason to have different modes. I'm only interested in the design / engineering reasons for ...
5
votes
3answers
1k 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 ...
5
votes
3answers
268 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 ...
5
votes
2answers
5k views

How can I set “vi” as my default editor in UNIX?

I believe I can do something like export EDITOR=vi, but I'm not sure what exactly to enter, and where. How can I set "vi" as my default editor?
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 ...
5
votes
1answer
673 views

Type from right to left

Is there a command to make Vim type from right to left? If not us any one aware of this plugin?
5
votes
3answers
901 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?
5
votes
1answer
89 views

How to put current line at top/center/bottom of screen in vim?

Any quicker navigation trick to place the line at which the cursor is at the moment to the top of the screen? center of the screen? bottom of the screen?
5
votes
1answer
643 views

VIM Executing a key command in a function

I have a function, and I want to execute a key command, but I get the error Trailing characters: function! MyFunction() if condition <C-W><C-W> else :some_other_command ...
5
votes
2answers
283 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
1answer
390 views

How is `vi` Aware of the Format of Configuration Files?

When I edit configuration files in vi, it seems like vi is aware of the syntax of the file. For example, vi will color tokens one way or another depending on whether its a key or a value. ...
5
votes
3answers
1k 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 ...
5
votes
2answers
912 views

How to re-run vim auto-indentation on a tex file?

I have a LaTeX source file with its indentation messed up. I am looking for a way to force vim (may be through one of vim-latex-suite commands) to re-run the automatic indentation commands over the ...
5
votes
2answers
2k 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 ...
5
votes
2answers
247 views

gvim pipes not reading zshrc when started from desktop

I'm using zsh as my default shell and using .zshrc to modify my environment variables. When I start gvim from terminal everything is fine however if I start gvim with the desktop icon, my env ...
5
votes
1answer
6k 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 ...
5
votes
3answers
1k views

Run a vim macro from inside a bash script

In a bash script I want to edit a file. Is there a way to write a macro in vim, save it and then call it in bash script?