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

learn more… | top users | synonyms

8
votes
2answers
210 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 ...
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
473 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 ...
7
votes
9answers
4k views

Compiling code from vim

New to vim and and I want to be able to compile code from within vim without running a new terminal and calling the compiler. How do I go about doing this? Note that this requirement is not ...
7
votes
2answers
427 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?
7
votes
5answers
6k views

vi command for adding blank line?

In vi, I can use o or O to add a blank line and go into insertion mode. But what if I want to stay in command mode, is there a command for this? In googling, I'm seeing suggestions to add stuff to my ...
7
votes
4answers
878 views

vim insert current filename into the contents

After some searching, I got to know :echo @% display's the current file-name in the bottom line of vim-screen. I would like to dump the file-name(with and without full path) into the contents of the ...
7
votes
4answers
11k 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 ...
7
votes
3answers
661 views

Temporary .vimrc

Is there a way to read a .vimrc file for only a single ssh session? That is, when I log in I perform some operation so that vim uses say /tmp/myvimrc until I log out? I do not want to permanently ...
7
votes
6answers
364 views

vi commandline, goto line and column

I have been mixing the use of emacs and vi (vim) for a long time. Each of them has its advantage. I parse error output from a compilation like process and get a line and column number but I can only ...
7
votes
3answers
2k 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 ...
7
votes
2answers
871 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 ...
7
votes
2answers
329 views

How do I get just the user-manual for Vim

To get the vim user-manual I am doing vi test and then, once the file is opened, I do :help user-manual This opens up a split window, which makes reading manual inconvenient to read. How do I ...
7
votes
1answer
3k views

Jump to specific character in a line in VI

In VI, I know that if you do :some_number and hit enter, you will jump to the line specified by "some_number". Is there an equivalent for jumping to a specific character in a single line? ...
7
votes
2answers
3k views

Turning off splitting lines in vim

One of the most annoying features of vim is splitting lines. For some reasons someone found it would be good to split lines even in whitespace sensitive formats. For example changing: echo ...
7
votes
2answers
2k views

How to make vim apply /var/log/messages syntax highlighting to any file called “messages” or “messages-*”?

I love vim's colorization of /var/log/messages, but it only works for that – the absolute filename. It doesn't work for older rotations of messages (e.g. /var/log/messages-20120610) or for messages ...
7
votes
2answers
2k views

Make sed ask for confirmation before each replacement?

Is there a way to make sed ask me for confirmation before each replace? Something similar to 'c' when using replace inside vim. Does sed do this at all?
7
votes
1answer
3k views

Setting vim filetype with modeline not working as expected

As per the accepted answer to this question, I'm attempting to use modelines in vim to force filetype detection in some files. For example, at the top of a file named gitconfig (note there is no ...
7
votes
3answers
536 views

Vim to print file on terminal and exit

I would like vim to do this in order to have syntax highlight as set up in vim (or without need for extra tools). So instead to use cat file | <some_sh_tool> I would use vim +"some_opts" +"..." ...
7
votes
2answers
2k views

Modeless vs modal editors

I just started learning Linux and all my previous experience of programming has been using the Windows platform. I came across Vim editor and read that it is modal editor unlike notepad which is ...
7
votes
3answers
362 views

VIM see regular expressions matches as you type

If I type /regex then the cursor temporarily jumps to the first match and all matches are highlighted. This updates as I type. Is it possible to get this behavior when I'm getting ready to make a ...
7
votes
2answers
1k views

red-green color blindness compatible vim theme

I am looking for a vim theme accessible to users with red green color blindness. In particular, the red text on a dark terminal background all but disappears. Do any of you know of a good theme? Or ...
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?
7
votes
1answer
147 views

Navigate through a stack of locations in vim?

Typing `` at location X brings you back to the last visited location in the text file. Hitting it again brings you back to X This switching is similar to Ctrl+6 to open the last opened file. But how ...
7
votes
1answer
3k views

How to set the bash display to not show the vim text after exit?

My question is simple, but I am finding it hard to frame/explain it easily. I log into several Unix boxes with different accounts. I see 2 different things for user1 and user2, while editing text ...
7
votes
1answer
2k views

Vim not running inside tmux

When I try to open a file using vim inside tmux the whole window freezes. I have to kill the window with C-a &. Here are my ~/.vimrc settings: :set autoindent :set ts=4 :set number :set ...
7
votes
1answer
6k 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 ...
7
votes
2answers
1k views

Fixing CTRL-* in vim under GNU screen

When running vim under GNU screen, I'm finding that combinations of CTRL with the arrow and Pg* keys don't work as expected. I'm using the Ubuntu 10.10 vim-gnome package. On a different machine, ...
7
votes
2answers
164 views

How do I only undo pasted text in vim?

TL;DR; version - How do I undo text that was pasted in from my OS copy buffer without undoing other text that was typed in since I went into insert mode? Longer description: Put something in your ...
7
votes
1answer
287 views

VIM: folding bullet points

I'm quite new to VIM, but have been trying to teach myself over the past week, yet I'm encountering a problem which has proven to be quite frustrating: Currently I'm mostly using VIM to take notes, ...
7
votes
3answers
475 views

Block motion for any bracket type?

If I want to, say delete a block, I can use text object motions. I.e if my text looks like this: (let [a 1 b {:x 3 :y 4}] a) And the cursor is for example on character 3. If I type diB ...
7
votes
2answers
351 views

Bash inside Vim not working properly

In MacVim I'm using Conque to run bash commands inside Vim. I have a problem with the text navigation while using Conque. If I'm at the end of a line of text and press down Alt← I skip a word to the ...
7
votes
1answer
461 views

Note-taking and outlining using Vi: On startup, highlight tags and display tags in a preview window [duplicate]

I am using vi as a note-taking and outlining tool and therefore I thought that this stackexchange site would be appropriate to ask this question. I am constructing the "tags" file by myself. What I ...
6
votes
6answers
11k views

How to comment multiple lines at once? [duplicate]

How can I select a bunch of text and comment it all out? Currently I go to the first line, go to insert mode then type # left-arrowdown-arrow and then I repeat that sequence, perhaps saving a few ...
6
votes
7answers
3k 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: ...
6
votes
5answers
798 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 ...
6
votes
4answers
3k views

less command and syntax highlighting

I need to use the less command with the syntax highlighting of the vim command for python, C, bash and other languages. How do I apply syntax highlighting colors according to vim colors for less ...
6
votes
5answers
2k views

Indent several lines with VIM?

For eample, I'm editing this code: <html> <body> <script> var a = 10; a += 100; </script> </body> </html> now I need to indent the script line: ...
6
votes
3answers
2k views

vim: How to switch to the directory listing from file view?

I have opened a dir vim some/dir. I can navigate within the tree, yet once I opened a file I wonder, how do I close the file view in order to go back to the directory listing to navigate to another ...
6
votes
4answers
7k views

Auto indent / format code for Vim?

I'm trying to use Vim more and more when I can. One of my biggest grip between Vim and an IDE like Aptana is the ability to auto indent. Is there a means of auto formatting code (HTML, CSS, PHP) so ...
6
votes
4answers
1k views

vim search around line breaks

When I am editing a LaTeX document in vim, often times I want to search for a phrase. Because I have LaTeX setup to wrap lines, sometimes half of the phrase will be on one line while the other half ...
6
votes
3answers
317 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 ...
6
votes
2answers
6k 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?
6
votes
2answers
2k 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 ...
6
votes
3answers
3k views

vi / vim - how to automatically strip trailing spaces on save?

Is there a .vimrc setting to automatically remove trailing whitespace when saving a file? Ideally (to be safe) I would like to only have this functionality for certain files, e.g. *.rb
6
votes
4answers
1k 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
402 views

vim - don't highlight search term after a search & replace?

After performing a search and replace, my installation of GVIM highlights any text remaining that still matches the search pattern. Example input text: foo foo fighters I run :%s/foo/bar/gc and ...
6
votes
3answers
684 views

Looking for a centred, full-screen terminal

There exist out there several different 'distraction-free editors' for writing: these provide a fullscreen, minimal environment with the goal of forcing oneself to focus on the task at hand. I want ...
6
votes
2answers
499 views

vim customized with emacs commands (insert mode only)

I was an emacs user, and I have to switch to vim. But I miss some basic emacs commands in vim insert mode: C-A C-E C-K C-Y C-x C-s ... and some other I know that I can press Escape and then press ...
6
votes
5answers
3k views

vim editing/switching between multiple files efficiently in large directory structures

I am by no means a vim power user, I am just beginning to grasp the advanced motions and commands with vim. But there's one drawback that I can't seem to get around. I grew up with graphical ...