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

learn more… | top users | synonyms

2
votes
3answers
2k views

How to turn off permanent highlighting of all braces (not just pairs) in vim [closed]

I have no idea how I modified vim such that all braces are highlighted, not just matching ones, but I want to turn it off now. How do I do that? The usual highlighting of matching braces works fine.
3
votes
2answers
712 views

In vi/vim, how do I append to a file instead of overwriting it?

I know I can write to a file by simply doing :w <file>. I would like to know though how can I write to a file by appending to it instead of overwriting it. Example use case: I want to take some ...
1
vote
1answer
60 views

Copy path from vim netrw

I use vim's netrw to explore some files. How can I copy the absolute path of the currently selected directory in netrw to a register and use it to paste into another buffer?
1
vote
1answer
54 views

Two different versions of VIM

When I install just about any distribution of linux it's accompanied with an unorthodox version of vi. I most recently dealt with this on Ubuntu 14.04. I can vi a file but a number of the "hot" keys ...
13
votes
1answer
18k 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 ...
3
votes
2answers
258 views

Why does insert-mode map “<F4>” unpredictably inserts itself or executes intended key strokes?

In Vim 7.3.1-762, mintty 1.1.2 (xterm), cygwin, Windows XP, the insert-mode map <F4> executes the intended key strokes at one time but inserts itself at another time. This undeterministic ...
18
votes
4answers
2k views

How do I insert the current filename into the contents in Vim?

After some searching, I got to know :echo @% displays the current filename in the bottom line of vim-screen. I would like to dump the filename (with and without full path) into the contents of the ...
21
votes
6answers
4k views

Vim interface on web browser input fields?

I am looking for a browser plugin which inputs textin of input boxes with the same keyboard interface of the Vim text editor. I have adopted Vimium which makes general navigation much more effective, ...
3
votes
2answers
2k views

How to fix the shifted function keys in vim in xterm in gnome-terminal?

When I hit the <s-f2> key to execute my nnoremap <s-f2> :set number! mapping Vim opens its "Insert" mode above (O) and types the 1;2Q string. In order to see the entire terminal key code – ...
1
vote
3answers
1k views

No syntax highlighting when editing crontab

I am trying to figure out why I don't have syntax highlighting when editing my crontab. I have both $EDITOR and $VISUAL set to /usr/bin/vim: > echo $EDITOR /usr/bin/vim > echo $VISUAL /usr/bin/...
22
votes
7answers
18k views

Are cygwin vim commands different than normal vim?

I am unable to edit text files using vim in cygwin. I have to press i many times to insert text. Sometimes it works and sometimes doesn't. Whenever I move cursor up down I have to press I many times. ...
0
votes
1answer
60 views

vi replacing characters on file opening

Whenever I open an existing file with vim, the first non-blank character in one of the lines gets replaced with a g. I am a beginner with vim and I might have entered a command by mistake (since I ...
0
votes
0answers
47 views

Vim not loading color scheme file at all

I have exactly same two CentOS 6 boxes. Trying to install vim and enable color scheme file. Same thing, same vim versions used but the color scheme works in one machine and not in other. Here are ...
10
votes
1answer
421 views

mutt: how to display emoji characters correctly?

I'd like to be able to see emoji characters properly in mutt, but e.g. 💗 shows up as ^J in mutt's pager. Running :set pager=view and re-opening the message displays the character correctly with ...
18
votes
3answers
9k views

How to automatically strip trailing spaces on save in Vi and Vim?

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
0
votes
1answer
20 views

sequentially number a line of linked images with vim or other?

I have over 400 lines of html containing this code for images: <a class='gallery' href="galimages/boards/board34.jpg" alt="board large"><image src ="galimages/boards/thumbs/34.jpg" alt="...
8
votes
3answers
1k 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 :%s/...
19
votes
3answers
4k 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?
93
votes
2answers
47k views

Ctrl-s hang terminal emulator?

I came across a sentence in vimdoc: Note: CTRL-S does not work on all terminals and might block further input, use CTRL-Q to get going again. and this key indeed hangs my vim. I was ...
3
votes
2answers
67 views

vim: Force specific syntax via command-line argument

When I want to easily read my PostgreSQL schema, I dump it to stderr and redirect it to vim: pg_dump -h localhost -U postgres dog_food --schema-only | vim - This gives: vim does not have a ...
12
votes
5answers
850 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
5answers
1k 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 ...
1
vote
1answer
84 views

How can my text file get filled with ^M characters all of a sudden?

I have a text file on a Mac machine, and I've only ever used vi/vim to edit it. Today when I opened it using vi I noticed a bunch of ^M characters everywhere. The only thing I did different today was ...
12
votes
6answers
15k views

Copy-paste for vim is not working when mouse (:set mouse=a) is on?

I was trying to copy paste something from vim to another application and also, from that application to vim using right click with mouse and then copy and paste (or with Ctrl+v and Ctrl+c and also ...
0
votes
0answers
29 views

Vim minimize current window and make remaining of equal size

I'm trying to get a mix of CTRL-W1| and CTRL-W=. I want to keep only 2 windows and make them of equal size so that they take all available space. I'm using vertical tabs all the time, but I guess ...
66
votes
9answers
30k views

Exit vim more quickly

I use Vim mainly for quick edits rather than long work sessions. In that sense, I find the keyboard sequence for quitting especially laborious: Esc, Shift + ;, w, q, Enter. How to quit Vim (possibly ...
0
votes
1answer
45 views

Vim color scheme not always working

I have changed my color scheme in vim by adding this line to .vimrc: colorscheme desert When I open .vimrc or .profile the text is colored, but when I do for example vim test.txt the text I enter is ...
0
votes
2answers
51 views

Vim writes to file without having permissions [duplicate]

$ ls sess.vim -lh -rw-r--r-- 1 root root 11K Feb 26 18:52 sess.vim I want this file to be readable for everyone and writable by no one (except by root). Thus I set its permissions to ...
0
votes
2answers
84 views

disable cursor color in putty client ssh terminal when in vi

I use putty.exe in windows 7 to connect to my Linux system. I use vi. I would like the cursor in vi to remain white all the time, and not change to green or blue around my if statement { } brackets ...
1
vote
1answer
60 views

Setting Terminal tab names in OS X and using vim

I regularly ssh into a Linux cluster from an OS X (El Capitan) Terminal, sometimes with multiple Terminal tabs. I use bash and vim. I'd like to do the following: while ssh'd, set the Terminal tab ...
84
votes
6answers
75k views

vim - better colors so comments aren't dark blue?

Mostly I edit ruby files, although shell script file comments are also # Currently my comments show as dark blue on black which is really hard to read. See screenshot. How can I change their color? ...
1
vote
1answer
19 views

Accessing to the lastly executed command and modify it before executing in VIM

Scenario. Imagine, that I want to search replace something. :%s/foo/bar/g Now, imagine that I made a mistype and executed the command :%s/fop/bar/g Every vim user knows than @: executes the ...
10
votes
2answers
3k views

Negative lookbehind/ahead assertions in Linux less pager (or vim)

I want to find all instances of "index" not followed by .php in a log using less. /index(?!\.php) does not work. Is this possible? What is the regex for less and vim (do they differ?). Is this not ...
1
vote
1answer
57 views

Gnome Terminal error with VT100 cursor movement codes

I've got an ansi escape issue with Gnome Terminal. What could be causing and how do I fix an issue like this? Since I cannot describe the issue very well I have a screenshot to show it off. When I ...
3
votes
2answers
435 views

How to effectively add a file to the args list for vim from within vim?

Really I just have a confusion between a few terms, some of which may be synonymous: buffers tabs files windows I want to understand these terms fully and any pointers in that direction would be ...
48
votes
8answers
48k views

How to copy text from vim to an external program?

I'm trying to copy-paste some text from vim. I'm doing v to enter visual mode, then y once I selected my block. It appears to copy the text into vim's clipboard, because p will paste it. But in ...
1
vote
1answer
42 views

Display replacement characters for no-break space in Vim

I'd want to display non standard spaces in Vim so that I could distinguish No-Break space (U+00A0) from Narrow No-Break space (U+202F) by using for example replacement Unicode characters like ␣ (U+...
4
votes
2answers
1k views

How can I search for and highlight multiple strings in VIM?

In VIM, how can I search for multiple strings and have a different color highlight for each match?
3
votes
1answer
697 views

How to use FileType in Vim?

In most cases, I want to use tabstop=4 while editing files. But for some types of file, like xml file, I want to use tabstop=2. I added au filetypedetect FileType xml,html,xhtml,javascript set ...
8
votes
3answers
2k 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, ...
0
votes
1answer
20 views

How to define a shell variable as equal to the version of Vim presently installed?

I am intending to write a shell script (if specifics are required, it will be executed in Zsh) that will determine the latest Vim patch via running: git pull origin master vernew=$(git describe --...
3
votes
2answers
70 views

Inspecting vi .swp file to preview recovery

Feel free to close this as a dupe if you can find a question that deals with this case. This is NOT about HOW to recover a .swp file in vi. I'm not sure if I want to recover. I want to preview what ...
0
votes
1answer
84 views

Vim color scheme not being applied

I'm trying to use this color scheme: https://github.com/Konstruktionist/vim/blob/master/colors/Kafka.vim Here is my ~/.vim/colors: xxx@xxx:~/.vim/colors$ ls -l total 16 -rw-rw-r-- 1 xxx xxx 15245 ...
1
vote
0answers
37 views

Getting Alt to Work in the Terminal with Tmux and Vim

I'm trying to make Alt + h/j/k/l switch tmux panes and vim windows. Yet for some reason my terminal (xfce4-terminal) and and Alt do not play nicely with each other. I got Alt + h/j/k/l to switch ...
1
vote
0answers
49 views

Global vim-like (hjkl) navigation with numlock & xmodmap?

I'd like to be able mimic vim's hjkl navigation everywhere in the system by utilizing num lock (or scroll lock), and making hjkl keys act as arrows whenever num lock is on, and regular behavior ...
3
votes
1answer
31 views

Vim: if specific version, then don't load plugin

I wonder what the best way is to decide whether or not some plugin should be loaded depending on some specific compilation/version of Vim. Any help would be appreciated.
2
votes
1answer
1k views

Use of ! in VIM

I have seen that sometimes :q works but sometimes we have to use :q!. This is the case for many commands. I was wondering what is the general use of ! in vim and when to use it. I tried to google this,...
6
votes
1answer
112 views

What is this view in vim?

What is this view in vim called, and what is it for? Somehow when I type colon to enter a command in vim I accidentally bring up a view that looks like this. But I can't get it to happen consistently,...
4
votes
2answers
345 views

Right-align comments in vim

I'm writing C code using vim and are searching for a possibility to right-align my comments so that they all end at col 80. To give a short example: int a = 80; /* initialize a */ int b = 7; /* ...
0
votes
0answers
70 views

Differences between Vim and Evil Mode Emacs

I normally use emacs on my system however all of the computers at my university have vim installed which I normally ignored (I know basic vim but I'm not very efficient) and used gedit when I needed ...