vim (Vi IMproved) is a text editor supporting different editing modes.
14
votes
3answers
4k views
How to fix Ctrl + arrows in Vim?
I am using Putty -> Suse box -> vim 7.2 combo for editing and want to remap Ctrl + arrows combo to a particular task. But for some reason, Vim ignores the shortcut and goes into insert mode and ...
34
votes
4answers
2k views
Becoming root from inside Vim
Sometimes I start editing configuration files in /etc using Vim, but forget to use sudo to start Vim. The inevitable result then is that after finishing my edits I encounter the dreaded notice that I ...
12
votes
2answers
6k views
Best way to upgrade vim/gvim to 7.3 in Ubuntu 10.04?
I have to use Ubuntu 10.04 at work, and cant upgrade it. I'm using Vim/gVim 7.2.
I want to upgrade it to 7.3 (with Python and Ruby extension support). Which is the best way? Add an entry in ...
9
votes
2answers
891 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 ...
5
votes
7answers
1k 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:
...
152
votes
14answers
44k views
What are the pros and cons of Vim and Emacs?
How would you compare these editors? What are the pros and cons of each?
[note] This is not meant to be answered by those who "hate one and love another" or those who haven't used both.
27
votes
8answers
18k 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 ...
22
votes
9answers
793 views
How to find out which file is currently opened in vim?
This may sound trivial but, on more than one occasion, I have found myself having forgotten which file in vim I have open (e.g. when I am looking through different log files and such) and the only way ...
5
votes
2answers
733 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 ...
5
votes
3answers
3k 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 ...
7
votes
8answers
2k 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 ...
10
votes
4answers
1k views
Replacing Multiple blank lines with a single blank line in vim / sed
Question more or less says it all. I'm aware that /^$/d will remove all blank lines, but I can't see how to say 'replace two or more blank lines with a single blank line'
Any ideas?
4
votes
1answer
547 views
Match word containing characters beyond a-zA-Z
To match a word one can use
\v(\w+)
From the vim help :h \w:
\w word character: [0-9A-Za-z_]
This works exactly as described in the manual. However, I want to
match words that contain ...
3
votes
1answer
292 views
Vi: On startup, highlight tags and display tags in a preview window
I am using vi as a note-taking and outlining tool. I am constructing the "tags" file by myself. What I would like to do is that when I open my notes or
outline file, vi reads the tags present in this ...
35
votes
6answers
20k views
How can I edit multiple files in VIM?
I know I can open multiple files with vim by doing something like vim 2011-12*.log, but how can I switch between files and close the files one at a time? Also, how can I tell the file name of the ...
21
votes
2answers
15k views
How can I set VIM's default encoding to UTF-8?
I'd like to contribute to an open source project providing translated strings. One of their requirements is that contributors must use UTF-8 as the encoding for the PO files.
I'm using VIM 7.3 on ...
19
votes
6answers
2k views
Using VI keys to edit shell commands in UNIX
I used to have a co-worker who was really good at UNIX.
He showed me how to use Vi key bindings to edit my shell commands.
He placed the command in a file that ran every time I logged in.
Since ...
24
votes
4answers
3k views
Why does `ESC` move the cursor back in vim?
In vim, when I hit ESC to return to command mode, the cursor moves one character to the left. This is not what I would hope for, occasional I immediately hit l to move back to that spot, perhaps to ...
16
votes
5answers
2k views
How to yank a particular line without moving the cursor in vim?
For example
How can I yank and paste Line 4 only to Line 12 without having to move the cursor to Line 4?
14
votes
3answers
12k views
Comparing two files in Vim
Is it possible to view two files side-by-side in Vim? If so, how can I set up my editor to do this, and is there a way to diff between the two files within Vim?
I am aware of the :next and :prev ...
18
votes
6answers
6k views
Vi vs vim, or, is there any reason why I would ever want to use vi?
I know a bit about *NIX text editors (currently migrating from nano to vim), and, after looking around a bit on the Unix & Linux SE, have noticed that a fair about of question use vi instead of ...
15
votes
4answers
4k views
How to get vim to work with tmux properly?
I'm trying to figure out how to get vim and tmux play together.
My problem is:
When I use xterm-256color I get vim to work nicely, but the background doesn't render properly.
I fixed this by using ...
7
votes
2answers
506 views
tmux, TERM and 256 colours support
Introduction
My question arises from the necessity of understanding why I have now (after multiple trials) Terminal and tmux which support 256 colours even with tput colors that tells me they are ...
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
7answers
972 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. ...
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
...
6
votes
1answer
281 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), ...
5
votes
1answer
342 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 ...
5
votes
2answers
967 views
Is it possible to create and use menus in (terminal-based) vim?
I'm setting up virtualized Linux boxes (as local development servers) for developers at a company that is primarily Windows-based, and some of developers make negative cracks about vim (among other ...
2
votes
1answer
752 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 – ...
11
votes
4answers
375 views
Is there a vim shortcut for <name of current file>?
In vim, if I'm working on a Python script, I will commonly type:
:! python this_script.py
to execute the script. Is there a shortcut for the name of the current file? If not, can I easily make one? ...
8
votes
2answers
1k 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.
5
votes
1answer
1k views
vim auto indenting even after setting noai option
I am using vim 7.2 from putty terminal.
Even if I run set noai it seems vim still trying to indent code.
I am copying my code from Notepad++ to vim.
following is from Notepad++
and following what I ...
4
votes
3answers
156 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 ...
4
votes
3answers
2k 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
4
votes
1answer
806 views
GNU Screen makes Vim ESC key slow
Screen makes my ESC key wait for more commands I beleive, and if it does not get those commands, it sends it to my terminal Session (which I am running VIM in). ESC is used alot in VIM and currently ...
3
votes
1answer
799 views
Saving with CTRL-s in vim
I have added this line in .vimrc so that pressing control-s saves the current file
:nmap <C-s> :w!<cr>
:imap <C-s> <esc>:w!<cr>
But this is not working. Any ...
3
votes
1answer
269 views
Clipboard over SSH session through VIM
I have a server running SSH, when I edit a file with vim on the remote server, :y+ doesn't work since the VIM binary on that linux system wasn't compiled with X support.
(E488: Trailing characters)
...
3
votes
2answers
634 views
The Right Distro for text-based needs
I'm searching for the right Linux Distro. My four current ideas are:
Gentoo
Grml
Arch
Debian
But I'm absoluty open to more alternatives. Now a little bit more about my needs:
I want it to be ...
2
votes
4answers
794 views
Turn NumLock on on startup?
I usually edit in Vim,and when pressing +, I'd rather move my hand to the right part of the keyboard where + resides rather than doing shift + =.
But when NumLock is not on, in Vim it just opens a ...
7
votes
1answer
2k 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 ...
5
votes
1answer
367 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
...
3
votes
4answers
640 views
vim search numbers containing specific number of digits
I need to find specific length numbers in a big document. I tried to use regex for this. For example, If I need to search for numbers with exactly 2 digits, I use /d/d (i.e. /d twice followed by a ...
3
votes
1answer
83 views
Switching to edit mode in VIM rc?
Still related to the previous question, but switching mode with exe "a" doesn't seem to work, I still have to press the a button manually
Here upon opening a newly created a file, a template is in ...
3
votes
1answer
530 views
gvim -p limit of opened tabs?
When I run :
gvim -p *.xyz
I find that not all files are opened in tabs.
It feels, like a kind of tab limit?
But ! When I try to open unopened with :
:tabnew
it is opened next to previous ...
3
votes
2answers
1k views
How to copy from one vim instance to another using registers
How can I select the + register? I have problems following the instructions below to copy/paste text from vim to another vim:
In the vim, highlight, select + register, and yank (save) to it:
Shift-v
...
2
votes
2answers
128 views
Command-line editing vim style [duplicate]
I recently discovered terminal's feature, you can set the keys emacs or vi style
I prefer the second. so if you do
set -o vi
You can use k j l h keys to navigate on the command line. And you can ...
2
votes
1answer
209 views
vim and tmux are conflicting. How can I fix this? [duplicate]
I'm having a painful experience with tmux. I'm using solarized in vim but when I run tmux then my vim configuration does not work. It's as if solarized is not configured in my .vimrc.
Out of tmux ...
2
votes
3answers
731 views
Unmet dependencies
I am trying to compile vim and install with "--enable-pythoninterp" flag, which needs the python-dev package.
INFO
I obtained the vim source from ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2
Vim7.3 ...
2
votes
4answers
6k views
How can I find and replace with a new line?
I have a CSV delimited by commas and I want to delimit it by newlines instead.
Input:
a, b, c
Output:
a
b
c
I've written Java parsers that do this stuff, but couldn't this be done with vim or ...