akshay
  • Member for 6 years, 10 months
  • Last seen more than a week ago
5 answers
66 votes
26k views
Vim search replace all files in current (project) folder
Accepted answer
67 votes

There are several ways to do this. Inside Current Directory If you want to perform the search/replace in a project tree, you can use Vim's argument list. Simply open Vim and then use the :args ...

View answer
2 answers
52 votes
44k views
What are the differences between :wq<cr> :x<cr> and ZZ when exiting vim?
Accepted answer
47 votes

From Vim's documentation, :x and ZZ are equivalent; they only save the file if it has been modified, then quit Vim: Write current file, if modified, and quit (same as ":x"). (Note: If there are ...

View answer
4 answers
21 votes
2k views
Clear a line faster than [0][d][$]
Accepted answer
36 votes

As you said, there are multiple ways, and you can also take into account on what your next action will be after you clear or delete the current line. dd will delete the current line (not clear) 0D ...

View answer
3 answers
42 votes
66k views
How to get intelligent C++ auto-completion
Accepted answer
34 votes

I really like clang_complete for this. It does require clang, and you need to tell it where libclang resides in your system. After that, it works wonderfully. People might suggest YouCompleteMe, but ...

View answer
1 answers
32 votes
11k views
What are the differences between the map, noremap, abbrev and noreabbrev commands?
Accepted answer
33 votes

First, map and noremap are similar in that that each create mappings for normal, visual, select and operator pending modes simultaneously. Vim details this in :help map-overview: Overview of which ...

View answer
2 answers
28 votes
5k views
Swap function arguments
31 votes

Without plugins | indicates cursor position func(foo[0], bar(), |baz.spam) Steps: dt) will delete baz.spam Ff will move the cursor to the character f in foo[0] vt,p will delete foo[0] and ...

View answer
10 answers
34 votes
81k views
How to enable +python feature in vim
Accepted answer
27 votes

You need to compile Vim yourself or get a prebuilt Vim package that was compiled with Python support. If you're on a Debian based system, the easiest way is to download the vim-gnome or vim-gtk ...

View answer
5 answers
23 votes
10k views
Can I do an interactive :substitute (search & replace)?
23 votes

In addition to what Carpetsmoker said: The &amp;incsearch (set incsearch) setting in Vim is really useful. You can use it together with a useful and little known trick. The trick is to try out your ...

View answer
5 answers
19 votes
23k views
List valid color schemes?
Accepted answer
22 votes

The easiest way is to use :help c_Ctrl-d after :colorscheme. So, :colorschemeCtrl-d will output the colorschemes you have available to you. Make sure there is a space after :colorscheme

View answer
4 answers
11 votes
3k views
How to delete content backwards until "=" at the previous line?
21 votes

Not sure if I totally understand the question, but if you wanted to delete until you only have var a = {};, you could, from the cursor position, use d?1Enter d takes a motion, and you can give it a ...

View answer
5 answers
23 votes
18k views
How can I create my own colorscheme?
Accepted answer
19 votes

Colorscheme locations First, Vim looks in its runtime folders for a colors directory. Here is where all the colorschemes should be stored (:help 'runtimepath') This means you will need one file that ...

View answer
6 answers
29 votes
19k views
Vim Code Completion for Python 3
Accepted answer
18 votes

The ideal way is to get Vim's source and compile it yourself. Step 1: For Debian-like systems, get the required packages: sudo apt-get build-dep vim Step 2: Clone Vim's source code: cd /tmp &amp;&...

View answer
2 answers
20 votes
7k views
How do I check the value of a Vim option in Vimscript?
Accepted answer
18 votes

You can use the &amp;{option-name} in an if-statement like so: if &amp;guioptions ==# "Trl" echo "Toolbars and scrollbars are present!" elseif &amp;guioptions ==# "" echo "No toolbars and ...

View answer
2 answers
8 votes
2k views
Vertical equivalent of "control+w n"?
Accepted answer
16 votes

From :help vnew: Like |:new|, but split vertically. If 'equalalways' is set and 'eadirection' isn't &quot;ver&quot; the windows will be spread out horizontally, unless a width was ...

View answer
2 answers
12 votes
5k views
Go to last non-whitespace character of previous/next line?
Accepted answer
14 votes

g_ moves the cursor to the last non-blank character of the current line. From Vim's :help g_: g_ To the last non-blank character of the line and [count - 1] lines downward |...

View answer
2 answers
12 votes
6k views
How do I install a .vimball Plugin?
Accepted answer
14 votes

Simply open the vimball file in Vim and then execute :source %. It will move the files to their appropriate folders in your ~/.vim directory. You don't need to be root as it just copies files to ...

View answer
3 answers
7 votes
303 views
Is there a way to set an option to the value of another option?
Accepted answer
13 votes

You can use the let command instead. Like so: let &amp;shiftwidth = &amp;tabstop The &amp; specifies that the variable name is a Vim option. You can also do :help let-option to know more about it: ...

View answer
1 answers
9 votes
393 views
How can I easily get the length of a piece of text?
Accepted answer
12 votes

You can set the showcmd option. From Vim's help: Show (partial) command in the last line of the screen. Set this option off if your terminal is slow. In Visual mode the size of the selected area is ...

View answer
5 answers
40 votes
4k views
Terminal borked after invoking Vim with xargs
12 votes

Workaround suggestion: use a buffer as a filesystem navigator Use the vim - command to read a list of paths from stdin. Vim's :help -- explains this:1 Start editing a new buffer, which is filled ...

View answer
1 answers
7 votes
4k views
Why vim cannot expand wildcards from the external command?
Accepted answer
11 votes

You were close. Enclose the path pattern in single quotes instead of double quotes for the find command like so: args `find . -type f -not -path '*/\.*'` By the way, a handy way to ignore hidden ...

View answer
1 answers
9 votes
4k views
Argument completion for python
Accepted answer
10 votes

By default, (with a minimal vimrc, and no plugins installed), this is already possible. Vim ships with multiple filetype plugins and some of these plugins offer omni-completion right out of the box. ...

View answer
1 answers
1 votes
4k views
How to split window directly from command line?
Accepted answer
7 votes

Vim's -o and -O options will open the files while splitting them horizontally or vertically respectively. Taken from Vim's help page :help -o and :help -O: *-o* -o[N] ...

View answer
1 answers
8 votes
220 views
How do I open a file using `gf` in case-insensitive manner?
6 votes

:set fileignorecase will treat file names and directories as case insensitive. It's on by default for some systems like OS X which comes built in with a case insensitive (but case preserving) file ...

View answer
1 answers
6 votes
2k views
Searching for text when launching Vim
Accepted answer
4 votes

You can leverage the -c argument which runs a the given command after Vim has loaded. With this, you can search with ":silent!" which supresses all errors like so: vim -c "silent! /foo" ...

View answer
2 answers
5 votes
8k views
Match everything before first occurrence of a character
4 votes

Vim has start and end anchors (\zs and \ze respectively) that you can use. In this case, the \ze anchor will help match what you're looking for: foo\ze\/ matches the "foo" in "foo/bar/baz" In this ...

View answer
1 answers
6 votes
85 views
When is a function or special character automatically evaluated / expanded and why?
Accepted answer
4 votes

It depends on the Ex command you're trying to use. The Vim documentation on echo and edit comes in useful here as it tells you what each Ex command it expects. :echo according to Vim's ...

View answer
2 answers
4 votes
4k views
I can't get 256 colours to work with Vim in iTerm2 on MacOS X
Accepted answer
4 votes

It looks like gruvbox sets italic on by default for the Comment syntax group if you're running terminal vim, which is a big problem if the terminal does not support italics. iTerm does but you have to ...

View answer
1 answers
4 votes
18k views
Change a font in Vim/GVim in a simple way
Accepted answer
3 votes

Reading the 'guifont' option is useful here. I do understand your frustrations with this option however. It seems that how you set the 'guifont' setting, is dependent on the OS. On macOS, you set '...

View answer
2 answers
4 votes
489 views
Repeating the last move using . (w followed by .)
3 votes

Vim answers this in the help about the dot command: . Repeat last change, with count replaced with [count]. Also repeat a yank command, when the 'y' flag is included ...

View answer
5 answers
47 votes
26k views
How to diff and merge two directories?
3 votes

I've wanted the same for a while. The best solution I found was to use vdwrap, which works amazingly well. All it does is wrap git difftool --dir-diff for vimdiff. It doesn't require any vim plugins. ...

View answer