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

learn more… | top users | synonyms

10
votes
5answers
560 views

VIM commenting out what I paste

I got this when trying to copy this gist on vim: https://gist.github.com/w0ng/3278077 I notice the same behaviour everywhere: If I paste something that includes a comment, everything that follows ...
10
votes
3answers
7k 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 ...
10
votes
5answers
2k 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 ...
10
votes
2answers
2k views

Can less invoke vim instead of the default vi when I hit the 'v' key?

I want to launch vim instead of the default vi editor when I hit v in less. Are there any settings I can modify to allow me to do this?
10
votes
4answers
24k views

How do I quit from Vi?

I started Vi on my Ubuntu machine. However I don't know Vi, and now I can not quit. I see the editor and I can write text, at the bottom line there is a label "recording". How do I quit from Vi?
10
votes
4answers
424 views

vim: hide first n letters of all lines in a file

I am analyzing log file using vim and the format looks like this YYYY-MM-DD HH:MM:SS.USEC PID Name LogText Since Most of the times I don't care about date and time. I want to hide them and just ...
10
votes
2answers
1k views

How to change the name of a vim buffer

Is it possible to change the name of a buffer in vim? Specifically, I'm using Conque Shell to open shells in vim (each shell is in a buffer) and with multiple shells, I see: 10: bash - 1 11: bash - ...
10
votes
2answers
2k 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 ...
10
votes
2answers
3k views

Copy text from one tmux pane to another (using vim)

I have two files opened in vim, each in one tmux pane. I would like to copy let's say 10 lines from one file to another. How can I accomplish this not using the mouse's Copy -> Paste ?
10
votes
4answers
2k views

Preserve modified time stamp after edit

For files within a specific folder, I would like vim to never touch "modified" timestamp at all. The background is that I use Bloxsom for blogging, which uses plain text files in ~/bloxsom as source ...
10
votes
4answers
2k views

How do I make Vim behave like “tail -f”?

I would like to know if there is a way to make Vim behave like tail -f. Even the best Vim plugin I've found so far doesn't do what I expect. I really want to see the file update in real-time. Even ...
10
votes
1answer
359 views

Can I make vim change its cursor behavior?

I've been using vim for a few years as a secondary editor but for various reasons, I find myself using it more and more even when my primary editor is available. One problem that has always bugged me ...
9
votes
5answers
4k 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.
9
votes
4answers
2k 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 ...
9
votes
2answers
2k 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) == ...
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 ...
9
votes
2answers
619 views

vim: use string from search in replace command

I often use vim / search command to verify my regular expressions (just to see what it matches). After that i usually use the :%s replace command, where i use that regexp from search as a string to be ...
9
votes
2answers
400 views

Trying to “locate” and then open a file

Suppose that I have a file named filename123.txt and it is the single file that is named so, and I can locate it with the command locate filename123. And it returns only this file. Now I want to open ...
9
votes
2answers
2k 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.
9
votes
2answers
795 views

vim - open file and goto line number using <filename>:<line nbr>:

Several tools such as grep, py.test, etc ... use the pattern <FileName>:<line number>: to point to errors. For example: ; grep -Hn Common setup.cfg setup.cfg:11: Common How can I ...
9
votes
2answers
792 views

How to set on executable bit for a particular file automatically

I want that when i make create a particular file, suppose i create it in vim editor, the created file should get executable permission as well when it gets created . I want this as i am creating some ...
9
votes
1answer
2k views

Vim: Making XML text “pretty”

Is there an easy way within vi to make your XML text "pretty"? For example: I want this.. <person> <name>Nick</name> <age>26</age> ...
9
votes
2answers
397 views

How do I modify the ci command in vim

Just like "ci(" changes everything between parentheses, I want "ci$" to change everything between dollar signs (for editing LaTeX.) Is this possible?
9
votes
1answer
2k views

Select lines using ranges in Vim?

I would like to select lines visually. Usually I'd SHIFT-V and select with j and k to highlight the lines. How do I do it using a colon-range command? e.g. :10,12<?> to select lines 10 - 12 ...
9
votes
3answers
644 views

GVim compiled from source opened via SSH -X does not copy paste on selection

I'm using SSH (with -X specified) from a Ubuntu box to a RHEL4 box and running GVim. It opens as expected in my local X, but the copy and paste via select doesn't work. I cannot select text in GVim ...
9
votes
3answers
233 views

Bash autocomplete with vim command

In bash, autocompletion of paths has recently stopped working when issuing vim commands where the path is deeper than two directories (it continues to work as expected with other commands, such as ls ...
9
votes
1answer
886 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 ...
9
votes
2answers
344 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) ...
9
votes
1answer
996 views

How to have tail -f show colored output with vim?

In this question, Gilles answered Yet another possibility is to run tail -f in an Emacs shell buffer and use Emacs's syntax coloring abilities. Because I'm a vim user, I'd like to do this with ...
8
votes
2answers
420 views

In VIM, replace path with slashes without using escape slashes

In vim I want to substitute a long path /a/b/f/g/d/g with another /s/g/w/d/g/r in a text file. Usually I use \/ but there are too many slashes here. Is there an easier way?
8
votes
5answers
14k 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 ...
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 ...
8
votes
2answers
449 views

Is there a command reverse search in vim?

In linux cli I can do ctrl-r and do a reverse search and choose something I have done easily. Is there something similar in vim? I mean I may run a command using : (could be anything like a long ...
8
votes
2answers
385 views

vim: Can I make *only* y perform a copy?

I'm learning to like vim, but one thing that I haven't yet fully embraced is the copy and paste situation. In a muggle text editor I would Ctrl-C copy a piece of text and then edit/delete and then ...
8
votes
7answers
1k 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. ...
8
votes
3answers
416 views

Vim: pasting lines line by line

Let's suppose I have a file containing: xxx yyy zzz and another file: kkk qqq ppp I want to obtain: xxxkkk yyyqqq zzzppp Is that possible in Vim with some command? (I've tried using VISUAL ...
8
votes
5answers
4k views

vim on FreeBSD does not react on arrow keys correctly and other vi-like behaviours

I tried to use vim on FreeBSD (via ssh on Linux xterm-compatible terminal). However vim behaves similar to vi out-of-box. For example it does not react on delete key, insert F character instead of ...
8
votes
1answer
345 views

Is there a way to move by screen lines in vim?

When editing files in vim, it is a small annoyance that when I move lines with j and k, it moves by file lines, rather than screen lines like other editors. With my own files, I can deal with this by ...
8
votes
2answers
725 views

vim spell checker?

Is there a way to spell check a file using vim?
8
votes
2answers
334 views

Vim command for inserting a character

I'm looking for the opposite of x. I want to insert just one character and stay in command mode.
8
votes
2answers
1k views

What encryption does vim -x use?

I read man vim, :h -x and :h encryption none of this actually says what algorithm it's encrypted with.
8
votes
1answer
979 views

What would cause vim not to retain command history?

On other distros I have run, vim remembers your command history even between sessions; this is especially handy when doing a lot of similar operations on different files. For some reason, it has been ...
8
votes
2answers
192 views

VIM: show all lines edited in session

Is there a command or plugin that I can use to show all the lines I have edited in a Vim session? I would like to be able to have all the changes I have made highlighted when working in co-workers ...
8
votes
1answer
3k 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 ...
8
votes
2answers
147 views

Vim spell punctuation for ⸮

I am finding myself using the point d'irony (⸮) more and more. However, vim spelling does not recognise it as a valid punctuation character. How can I add it to vim so that the spelling works?
8
votes
3answers
5k views

disabling mouse support in `vim` in a `gnome-terminal` environment

Edit: The problem of an enabled mouse in vim appears to be specific to gnome-terminal (version 3.4.1.1-1; I am using gnome 3 fallback mode). If I run xterm, mouse support in vim is disabled by ...
8
votes
1answer
178 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).
8
votes
1answer
1k views

screen + vim — Any way to automatically set screen window name to open vim filename?

I have a pretty nice screen rc file that shows me the open screen windows almost like tabs at the bottom of the terminal. Currently the windows are named according to my prompt which is not so useful. ...
8
votes
2answers
202 views

Vim - map last shell command to the key

Is there any way to map leader-r to repeat last command sent to bash? For example, when working with C files I would like to compile and run program from vim without typing :!make or gcc. I know I ...