Vim is a highly configurable text editor built to enable efficient text editing. It is an improved version of the vi editor.

learn more… | top users | synonyms

13
votes
5answers
16k views

How can I recover the original file from a .swp file?

I tried opening the .swp file using vi and cat but it displays junk.
3
votes
1answer
303 views

How to keep in visual mode after identing by shift+> in vim?

Current it quits the visual mode after indenting once,which is very annoying.
0
votes
0answers
16 views

vim gets stuck at top or bottom

When I scroll to the top or bottom of a document using a pressed j and k, vim temporarily gets stuck (around one second) as if it has to finish clearing the keyboard buffer. Can I correct this issue ...
2
votes
4answers
56 views

Vim copy/paste messing up indentaton

Whenever I copy something from another application and then go to paste it into vim, it messes up the indentation. For example, just now I tried to copy the manifest.json file from the hello-world ...
1
vote
1answer
65 views

How to “Edit with Vim” as administrator in Windows?

When you install gvim in Windows, you get a right-click Explorer context menu item: "Edit with Vim". Is there a way of either adding a "Edit with Vim as Administrator", or just changing the existing ...
0
votes
0answers
14 views

Can I get vim to install bundles and close in the background?

I've been playing around with Dockerfiles, and in setting up a development environment, there is one manual step I haven't been able to work around yet. To install the bundles in my vimrc, I have to ...
7
votes
5answers
14k views

How to get rid of the warnings when opening a file that has a .swp file?

How can I get rid of the annoying warnings when I open a file that has a .swp file? Or, how do I not generate the .swp files at all? Example warning: E325: ATTENTION Found a swap file by the name ...
8
votes
1answer
1k views

How to refresh vim layout when split

After setting up some splits/vsplits and resizing gvim or the console running vim, splitter positions are not updated. Is there a way to force updating splitter positions (by retaining them in the ...
0
votes
1answer
18 views

Vim macro: increase last number of a line by 1

I have a csv file whose last column contains either integers, or the character "-". I need a vim macro that does the following: If last element of current row is "-": Turn "-" to "1" Else ...
17
votes
2answers
3k views

How can I paste something at the end of the line in VIM?

How can I paste some text that I yanked at the end of the line? Currently I'm doing it by pressing $p. Is there any way to do this with a single keystroke?
3
votes
1answer
207 views

Anyone know how I can use the same keys to move between Vim windows as well as Tmux (or tiling WM) panes?

Anyone know how I can use the same keys to move between Vim windows as well as Tmux (or tiling WM) panes? For example when I use my key combination to move to the right pane within VIM, VIM should ...
64
votes
5answers
25k views

The best way to make MacVim's vim (console, not mvim) the default instead of Mac OS X's vim?

I installed MacVim using homebrew. (brew install macvim). If I call mvim from cmd, it opens the GUI MacVim. I would like to make vim call the MacVim's Vim ...
1
vote
1answer
38 views

$HOME is not defined for root user on Ubuntu 14.04

On a fresh Ubuntu 14.04 install, the bash environment for the root user does not have $HOME defined. I need to run some apps from a root shell, for example: gdb /usr/sbin/apache2 This is difficult ...
1
vote
1answer
21 views

How can I create a macro to compile a CoffeeScript file I am editing from inside VIM?

I am writing a lot of CoffeeScript in VIM and I compile it very frequently by typing : coffee -c %. How can I easily create a macro so I don’t need to keep typing this?
2
votes
1answer
33 views

Can I make Vim's fold indicators visually subtler?

Fold indicators in vim are prominent because they take up the entire window width: void foo() { +--- 10 lines: int x;----------------------------------------------------------- } which makes ...
3
votes
0answers
85 views

How to prevent security flows caused by sudo vim? [closed]

I learned doing sudo vim causes security problems. For example, user_name ALL=(ALL) /usr/bin/vim /etc/httpd/confs/httpd.conf or %group_name ALL=(ALL) /usr/bin/vim ...
10
votes
6answers
4k views

How to close buffer without closing the window?

I usually open a few windows and keep some buffers open. Since my MO in buffer exploring is to use quick shortcuts to :bn and :bp, I want to close unneeded buffers from distracting my buffer surfing. ...
9
votes
3answers
802 views

Why does the system have /etc/sudoers.d? How should I edit it?

Last time, I asked about the risk of these (in /etc/sudoers): user_name ALL=(ALL) /usr/bin/vim /etc/httpd/confs/httpd.conf %group_name ALL=(ALL) /usr/bin/vim /etc/httpd/confs/httpd.conf ...
2
votes
1answer
18 views

Check if vim is compiled with +X11 in .vimrc

I have two copies of vim installed. One is installed with macvim and necessarily configured with -X11 (to work with Cocoa), while the other is configured to +X11 (used in terminal, to work with a ...
0
votes
1answer
29 views

How to autocomplete python class in vim

In sublime text 3, if I'm editing a file.py and I type class it will automatically create this for me class ClassName(object): """docstring for ClassName""" def __init__(self, arg): ...
0
votes
1answer
15 views

vim find buffer by absolute path

How can I find a buffer in vimscript when I have an absolute path, and as you know vim buffer names can be relative path? Is there a function for that?
0
votes
0answers
15 views

Is it possible to restart the internal python in Vim?

I'm running custom python code in my vimrc and If I often find myself in the position where I'm editing modules used by the vimrc, which causes script failures until I restart vim and its internal ...
0
votes
1answer
36 views

Vim: Managing multiple wording alternatives

(After reading this, please suggest another wording for the question, because I couldn't come up with a better one) When writing and editing in Vim, whether texts for humans or texts for humans and ...
1
vote
2answers
45 views

Open the output of a shell command in a split pane

I'm quite new to vim, so sorry, if the question is stupid. Consider any interpreted programming language. I can run the currently opened script using ! interpreter %, and use the return key to ...
8
votes
2answers
5k views

How do you change the default colorscheme in gvim?

In GVIM for Windows I know you are supposed to be able to add something to the $VIM/_vimrc file in order to customize the start up and I have managed how to figure out a few neat tricks with that but ...
26
votes
7answers
11k views

Vim: How to synchronize NERDTree with current opened tab file path?

When I open a new tab with different path from the previous file in VIM, NERDTree will still remains the same directory hierarchy of the previous file. Is there a sync shortcut to change the current ...
2
votes
1answer
41 views

MacVim / Vim retain content of all buffers (like Sublime Text). Preserve swap?

TL;DR: Can Vim store its swap files, and loads the same set of swap files and buffers on load every time? I'm on a Mac (OS: Maverick), where a number of application keeps the data in some sort of ...
1
vote
3answers
933 views

In Vim, how I can set a local match only for a specific filetype?

In Vimenter link description here, I can set local configuration as: setlocal number How I can set a local match only for a specific filetype? I use this: autocmd! BufEnter ...
5
votes
1answer
113 views

Tmux copy mode: stay in copy mode after selection

When using tmux, I often find a need to copy multiple items from one pane or window into another. When those items are located close to each other in a long scrollback buffer, my current workflow ...
24
votes
5answers
3k views

Vim - select text highlighted by search?

In vim, I often perform searches to hop to a word or phrase instead of navigating there with h/j/k/l. Then I hit n to hop between occurrences. Say I've got this text: Time flies like an arrow; fruit ...
11
votes
3answers
5k views

vim new line with same indentation

Then I press [Enter] in insert mode, there is a new line. But cursor places in the very beginning of a line. What do I do to create new line with the same indentation as the current's?
0
votes
1answer
17 views

Latex: customising syntax highlighting in vim

I made some custom commands to make writing equation blocks easier: % Equation starters \newcommand{\eqn}[1]{\begin{equation} #1 \end{equation}} \newcommand{\eqns}[1]{\begin{equation*} #1 ...
-3
votes
1answer
40 views

Set nano as a default editor over Vim [duplicate]

Every time I login to ssh terminal to edit files I execute the command export EDITOR=nano How Could I set nano as default editor so I shouldn't execute this command anymore
0
votes
1answer
37 views

How to permanently correct syntax highlighting after “?>”?

In Vim, I have a PHP script that contains a line similar to the following: $return = "<?xml attributes=\"values\" ?>"; Normally, the ?> characters will close an opening <?php tag, ...
0
votes
0answers
17 views

Can vim/gvim show “self” when editing a Ruby file?

When editing Ruby files in gvim, I'd like to be able to see which Ruby context the cursor is in. For example, if I have a file with several nested modules and classes, I want to be able to see what ...
0
votes
1answer
58 views

The risk of vim -Z (rvim)

Last time I asked about the way to prevent risks caused by these configurations: user_name ALL=(ALL) /usr/bin/vim /etc/httpd/confs/httpd.conf or %group_name ALL=(ALL) /usr/bin/vim ...
0
votes
1answer
26 views

Confusing end of line characters in Vim

How to view in Vim if there is any end of line character at the end of the file? If file content is '1234' as by echo -n 1234 > file.txt Vim shows (with :set list option) '1234$'. If file content ...
0
votes
0answers
37 views

Vim colorscheme not displaying properly

I realize that questions about Vim colorschemes have been asked quite frequently, but I believe I've tried the advice in all of them and I can't quite seem to get my colorschemes to work. That being ...
0
votes
1answer
22 views

Case insensitive search with accents

How can I tell Vim to search for a certain pattern in a case insensitive way taking into account also characters with accents? For example I would like to have /ü match both the capital U in Über and ...
1
vote
3answers
3k views

tgetent() not found while compiling vim

Currently I'm trying to install the YouCompleteMe extension to my vim setup, but it requires my vim to have the version of 7.3.584 or higher. The vim shipped with my Ubuntu 12.10 is 7.3.547, so I had ...
0
votes
2answers
49 views

Turn off vim's `filetype indent` for a specific filetype

In my .vimrc I have filetype indent on Now, the way it attempts to auto-indent yaml files is very confusing for me, so I want to turn filetype indent off, but only for yaml files, not for other ...
0
votes
0answers
33 views

Why doesn't Ctrl+[ (control + left bracket) work in GVim on Windows 8?

I'm on a macbook pro with a bootcamp partition running Windows 8.1. This problem also occurs on my PC with Windows 8.1 as well. In GVim, pressing Ctrl + [ should be equivalent to Esc but it does not ...
44
votes
8answers
25k views

How can I open a file read-only from command line with emacs/vi/vim

Is there a way to tell emacs/vi/vim (from the command line) that I want to view the file in view-mode or read-only. I know how to open a file as read only if emacs/vi/vim is already running.
7
votes
4answers
3k views

How to invert the selection in vim?

After selecting a range of lines with the V command, I would like to delete every line of the file that is NOT selected, so is a way to invert the selection -- select every line that is not selected? ...
0
votes
1answer
16 views

Scrolling through results of vim's silversearcher plug in

When I use :Ag "pattern" Let's say it finds 5 results and to scroll through them I use "cn" but it opens each one I scroll through in the buffer. Is there a way to open just the one I scroll to and ...
3
votes
2answers
1k views

Mouse scrolling in vim through tmux, how to configure?

I'm using a combination of PuTTY, tmux and vim. If I just open an SSH connection with PuTTY and then open vim, mouse scrolling works as expected. But if I open tmux and then open vim inside tmux the ...
0
votes
2answers
508 views

Mouse scrolling down in vim inside tmux via PuTTY, but not up

I'm experiencing an issue across multiple platforms where scrolling down with the mouse wheel works fine, but not scrolling up, while using vim within a tmux session within PuTTY. Any ideas? Maybe ...
0
votes
0answers
19 views

Bind Unite to <C-p> in vim

I love vim, and I personally think that CtrlP's trick of binding to <C-p> only when I'm not using it to yank-pop is awesome. Is there any way I can do this my self with Unite? Specifically: ...
1
vote
3answers
432 views

Git for Windows: Run vim in background without ampersand (&)

On my Windows machine, running gVim appears to tie up the git for windows shell, whereas if I run from the command prompt, this is not the case. How might I be able to run gVim (or any other program, ...
0
votes
4answers
1k views

Vim sync to remote on save

I'm looking for a plugin or script that works similarly to Sublime SFTP Basically, it should contain a configuration file and map the local and remote hierarchy. On save to a file, it should be able ...