All Questions
479
questions
3354
votes
35
answers
1.4m
views
How do I make git use the editor of my choice for editing commit messages?
How do I globally configure git to use a particular editor (e.g. vim) for commit messages?
2413
votes
34
answers
982k
views
Indent multiple lines quickly in vi
It should be trivial, and it might even be in the help, but I can't figure out how to navigate it. How do I indent multiple lines quickly in vi?
2017
votes
22
answers
952k
views
How to duplicate a whole line in Vim?
How do I duplicate a whole line in Vim in a similar way to Ctrl+D in IntelliJ IDEA/ Resharper or Ctrl+Alt+↑/↓ in Eclipse?
1506
votes
27
answers
631k
views
Turning off auto indent when pasting text into vim
I am making the effort to learn Vim.
When I paste code into my document from the clipboard, I get extra spaces at the start of each new line:
line
line
line
I know you can turn off auto ...
1422
votes
16
answers
999k
views
How do I move to end of line in Vim?
I know how to generally move around in command mode, specifically, jumping to lines, etc. But what is the command to jump to the end of the line that I am currently on?
1104
votes
38
answers
1.1m
views
How can I make Vim paste from (and copy to) the system's clipboard?
Unlike other editors, Vim stores copied text in its own clipboard. So, it's very hard for me to copy some text from a webpage and paste it into the current working file. It so happens I have to either ...
830
votes
70
answers
134k
views
What are the dark corners of Vim your mom never told you about? [closed]
There are a plethora of questions where people talk about common tricks, notably "Vim+ctags tips and tricks".
However, I don't refer to commonly used shortcuts that someone new to Vim would find cool....
797
votes
30
answers
531k
views
Differences between Emacs and Vim
What practical, objective differences are there between Emacs and Vim? For example, what can be done using one but not the other (or done more easily with one than the other)? What should I know in ...
790
votes
28
answers
1.3m
views
Copy all the lines to clipboard
Is there any way to copy all lines from open file to clipboard in VI editor. I tried yG but it's not using clipboard to store those lines.
So is it possible?
465
votes
34
answers
276k
views
What are the benefits of learning Vim? [closed]
As a programmer I spend a lot of hours at the keyboard and I've been doing it for the last 12 years, more or less. If there's something I've never gotten used to during all this time, it's these ...
390
votes
11
answers
169k
views
Using Vim's tabs like buffers
I have looked at the ability to use tabs in Vim (with :tabe, :tabnew, etc.) as a replacement for my current practice of having many files open in the same window in hidden buffers.
I would like every ...
362
votes
12
answers
98k
views
How can I swap positions of two open files (in splits) in vim?
Assume I've got some arbitrary layout of splits in vim.
____________________
| one | two |
| | |
| |______|
| | three|
| | |
|___________|...
301
votes
5
answers
265k
views
Go to first line in a file in vim?
How do I go to first line in a file in vim ?
259
votes
10
answers
138k
views
Disabling swap file creation in Vim
Is there a way to disable the creation of .swp files in Vim? Or, at least create them in one place so that I can find and delete them easily?
I find swap files especially annoying when I copy the ...
213
votes
6
answers
64k
views
Saving vim macros
Does anyone know how to properly save/reuse macros recorded inside of a vim editor?
212
votes
11
answers
73k
views
How do you return from 'gf' in Vim
I am using Vim for windows installed in Unix mode. Thanks to this site I now use the gf command to go to a file under the cursor.
I'm looking for a command to either:
return to the previous file (...
209
votes
13
answers
124k
views
How to comment out a block of Python code in Vim
I was wondering if there was any key mapping in Vim to allow me to indent certain lines of code (whether those lines have been selected in visual mode, or n lines above/below current cursor position).
...
209
votes
60
answers
59k
views
What is the best way to force yourself to master vi? [closed]
A good while ago, I read an article by the creator of viemu, clearing up a lot of the misconceptions about vi, as well as explaining why it's a good idea (and why it's been very popular for the last ...
203
votes
14
answers
89k
views
How to paste in a new line with vim?
I often have to paste some stuff on a new line in vim. What I usually do is:
o<Esc>p
Which inserts a new line and puts me in insertion mode, than quits insertion mode, and finally pastes.
...
198
votes
7
answers
40k
views
Delete text in between HTML tags in vim?
I know
di<
will delete in an HTML tag itself.
Is there an easy way to delete text in between two tags?
<span>How can I delete this text?</span>
Thanks!
165
votes
38
answers
57k
views
Favorite (G)Vim plugins/scripts? [closed]
What are your favorite (G)Vim plugins/scripts?
159
votes
7
answers
86k
views
Can you grab or delete between parentheses in vi/vim?
Given this line of code in C:
printf("%3.0f\t%6.1f\n", fahr, ((5.0/9.0) * (fahr-32)));
Is there a way to delete or yank from the first bold parenthesis to its matching parenthesis? I thought about ...
140
votes
11
answers
68k
views
How can I maximize a split window?
Invoking :help in Vim, I got the help manual page with split window. I want to maximize the help manual window and close the other window.
How can I do this? What is the Vim command to do this?
125
votes
17
answers
145k
views
Vim file navigation
I'm trying really hard to learn vim after using TextMate for the last few years.
I've started to commit some of the in-file navigation to memory but I'm struggling with navigating between multiple ...
117
votes
6
answers
63k
views
Find and Replace within selection in `vi`
How do I do a Find and Replace within a selection in vi?
101
votes
10
answers
86k
views
Vim yanking range of lines
I'm a C# developer who has just recently decided to expand my knowledge of the tools available to me. The first tool I've decided to learn is Vi/Vim. Everything has been going well so far, but there ...
98
votes
16
answers
61k
views
How do you prefer to switch between buffers in Vim?
I've tried MiniBufExplorer, but I usually end up with several windows showing it or close it altogether. What I'd like is something like LustyJuggler with incremental search, the way I switch between ...
93
votes
7
answers
32k
views
Is there an interactive way to learn Vim? [closed]
Years ago I was looking for a way to learn Vim that didn't involve a wall of text, or scrolling through vimtutor without knowing the commands to do so. I wondered if anything else existed for such a ...
92
votes
4
answers
54k
views
VIM: How can i open a file at right side as vsplit from a left side NerdTree panel?
I installed NerdTree plugin.
How can i open a file at right side as vsplit from a left side NerdTree panel ?
91
votes
5
answers
33k
views
Vim - yank into search register
Is there any easy/quick way to "yank" into vim's "last search" register ("/)?
From the vim documentation, it appears that the answer is no, but that it can be assigned via a "let" command:
It is ...
90
votes
12
answers
39k
views
How to navigate in large project in VIM
How do you manage big projects (hundreds of files) using only VIM?
I personally start having problems in any larger than small project.
is there any way to quickly 'go to file', preferably with name ...
83
votes
6
answers
114k
views
How to do column editing in vim?
Vim is pretty powerful when editing by line - the search/replace tools are modeled to work linewise.
But what if I want to change a particular column across all lines? For example, how can I change ...
68
votes
3
answers
31k
views
Find and replace whole words in vim
To find and replace all instances of a word in vim, I use
%s/word/newword/g
How do I change this so that it only finds instances of "word" that are whole words?
68
votes
4
answers
32k
views
git rebase --editor=/something/other/than/vim? (for easier squashing)
I happily use vim as my default editor for commits, and do not wish to change it. However, when it comes to rebasing, I find myself squashing dozens and dozens of commits which I find much easier with ...
65
votes
5
answers
45k
views
Opening files in Vim using Fuzzy Search
I'm looking for a way to make Vim have the ability to open a file by fuzzy-searching its name.
Basically, I want to be able to define a project once, and then have a shortcut which will give me a ...
62
votes
6
answers
25k
views
How to launch an EDITOR (e. g. vim) from a python script?
I want to call up an editor in a python script to solicit input from the user, much like crontab e or git commit does.
Here's a snippet from what I have running so far. (In the future, I might use $...
59
votes
7
answers
32k
views
Undo all changes since opening buffer in vim
How can I undo all changes since opening a buffer? I imagine there may be some form of :earlier that does this.
UPDATE: Many are suggesting solutions for traversing to earlier file writes. This isn't ...
59
votes
6
answers
24k
views
How to save all files in tabs on Vim?
If I have multiple files in tabs on VIM and I edit few of them. How to save them with one command?
58
votes
4
answers
68k
views
How do I delete the last character in each line using vim
I have a file:
12345a
123456b
1234567c
12345678d
123456789e
How do I delete the last character in each line.
And the file will be
12345
123456
1234567
12345678
123456789
58
votes
3
answers
40k
views
In vim, how do I highlight TODO: and FIXME:?
In vim, FIXME and TODO are highlighted, but I can't get FIXME: and TODO: (note the colon after the keyword) to highlight? What should I put in my .vimrc to make this happen?
57
votes
6
answers
17k
views
In vim, is there a plugin to use % to match the corresponding double quote (")?
The % key is one of the best features of vim: it lets you jump from { to }, [ to ], and so on.
However, it does not work by default with quotes: Either " or ', probably because the opening and ...
56
votes
29
answers
36k
views
Is it worth investing time in learning to use Emacs?
Right up front: I do not want to start a religious war.
I've used vi for as long as I can remember, and the few times I've tried to pick up Emacs I've been so lost that I've quickly given up. Lots of ...
52
votes
4
answers
54k
views
How do I jump to the beginning of line in vim?
How do I go to the beginning of the line in vim editor in normal mode?
Is it possible to using my Home key on keyboard on Linux?
50
votes
4
answers
39k
views
How to edit a diff/patch file cleanly ? Are there any patch file editors?
Scenario: I have a patch file that applies cleanly to my working files, but I do not want all the changes from the patch.
Usually, I do vim example.patch, remove unwanted changes and them apply ...
48
votes
3
answers
11k
views
Automatically scroll screen in vim when near top/bottom?
I would like to have smarter screen scrolling when I'm editing. When I reach within X number of lines from the top/bottom of the screen, I would like it to scroll the screen as I continue moving the ...
47
votes
10
answers
20k
views
Align text on an equals sign in vim
I tend to align code on equal signs for better readability. From this:
$ = jQuery.sub()
Survey = App.Survey
Sidebar = App.Sidebar
Main = App.Main
To this:
$ = jQuery.sub()
Survey = App....
45
votes
2
answers
10k
views
Reflowing comment blocks with vim
I'm cleaning up someone else's code and working with vim. I'd like to reflow the comments so that they're formatted consistently.
For example:
# one two three four five six seven
# eight ...
44
votes
2
answers
88k
views
Vim: No write since last change, even though I changed the file [duplicate]
I'm trying to set up a file on my ubuntu machine, but when I try to change the contents before saving the file I've just created, vim returns the error: No write since last change.
I've created the ...
39
votes
9
answers
39k
views
Vim for Word (or something like it)
Are there any rich-text editors that have Vi(m) keybindings? Specifically, something like Word where I can compose a document with colors, headings, et al. but use Vi(m) bindings to move around and ...
38
votes
18
answers
11k
views
I am looking for tips for learning Vim or Emacs the smart way
I am a quite happy user of Eclipse (I mostly develop in PHP and Python), however I found the answers to "What specific productivity gains does Vim/Emacs provide over GUI text editors?" interesting ...