All Questions

Filter by
Sorted by
Tagged with
36 votes
8 answers
3k views

How do I move vertically until reaching a non-whitespace character?

In a very long file with (accurately-) indented code, it may be helpful to move directly to a line of text above or below the cursor which delimits the indenting. (One way of doing this could be via ...
alxndr's user avatar
  • 1,356
35 votes
4 answers
46k views

Fully disable mouse in console vim

I saw completely disable mouse in console vim on Stack Overflow. It sounded like exactly what I wanted, but there the problem was related to Cygwin, so the title was a misnomer. I want to know how ...
James M. Lay's user avatar
34 votes
5 answers
3k views

Is there a text object for the entire buffer?

I often find myself typing commands like gg"+yG or ggdG and would like a more efficient way to do this without having to move the cursor twice. Is there any command that I can use e.g. y[movement] to ...
Random832's user avatar
  • 1,192
34 votes
5 answers
10k views

What is the easiest way to insert Unicode characters into a document?

When writing documents occasionally I want to insert Unicode characters into the text. Sometimes I know the character code and sometimes I look it up on the web. Currently I go to insert mode and ...
Martin York's user avatar
  • 6,270
34 votes
2 answers
21k views

Execute current buffer as bash script from vim

I use vim for bash scripting, and sometimes I write a one-time script. Usually, I don't want to create a new file, make it executable, execute it and then remove it. For instance I open vim and type ...
St.Antario's user avatar
  • 1,087
34 votes
5 answers
3k views

Performing certain operations without clearing register

Frequently, in configuration files I might copy and paste a block of lines, then I want to make small changes to that block. After pasting, I use x to delete characters that I want to remove, then ...
durron597's user avatar
  • 2,051
34 votes
5 answers
3k views

How to replace a word with a yanked word in normal mode?

When I have to replace a word with another word I yank before, I usually use a workflow which seems unnatural to me: Let's say I have this text: foo bar buzz And I want to yank foo and replace bar ...
statox's user avatar
  • 48.5k
33 votes
7 answers
16k views

Can I join lines with a comma (or another character)?

I know I can join lines in Vim with J and several variants thereof (gJ, etc.); J will "Remove the indent and insert up to two spaces". But is there also a straightforward way to insert another ...
Martin Tournoij's user avatar
33 votes
5 answers
25k views

Biggest differences between Vim and vi

Today, I decided to try vi instead of Vim; I wanted to see how different it is. I didn't notice much differences at all. The biggest thing I noticed was how vi didn't say -- INSERT -- when I went ...
Loovjo's user avatar
  • 451
33 votes
4 answers
10k views

Delete from cursor till nth occurence of character x

I know that I can delete from the cursor till and including the first occurence of a character x with d/x<CR> or with v/x<CR>d if I want to see the selection first and then delete. How can ...
user2609980's user avatar
33 votes
8 answers
16k views

Faster way to move a block of text

Here's how I usually copy a block of text or code: Select the block with Visual mode (V) and delete it with d; or if it's just a single line, just use dd. Go to where I want the text to be, I am too ...
Martin Tournoij's user avatar
33 votes
5 answers
9k views

How to use an external command in Vim to modify selected words and lines?

Something I've found useful in other editors is the ability to: take the selected text run an external command and pass the selection to its stdin take the external commands stdout and replace the ...
ideasman42's user avatar
  • 3,613
33 votes
1 answer
12k views

Can I search for a Unicode combining character in Vim?

I have a file with the character ã (lowercase a + combining tilde). Encoding and fileencoding are both utf-8. ga shows <a> 97, hex 61, octal 141 <~> 771, Hex 0303, Octal 1403 (but ...
cxw's user avatar
  • 934
33 votes
1 answer
10k views

How do you open a new buffer in the current window?

I've got a few tabs open with different window setups. I'd like to open a new blank buffer in the current window, without having any more splits/windows or tabs Is there any way to do this? I know ...
JonnyRaa's user avatar
  • 1,131
33 votes
4 answers
40k views

When to use :grep and :vimgrep in vim?

In vim :make makes it easy to build and fix errors, and :grep and :vimgrep behaves like :make. But why do you need these two commands? Why not just search for the pattern and just press n? What are ...
Qian's user avatar
  • 433
32 votes
5 answers
14k views

Git Fugitive how to git add a visually selected chunk of code

I would like to know if i could select some code in visual mode and git add it ? I checked with fugitive.vim but i didn't find how to do it. Is it possible ? Or is there any other plugin to do it ?
albttx's user avatar
  • 1,125
32 votes
3 answers
5k views

How to apply a setting in all open tabs and windows?

Is there an option to apply a setting in all tabs and windows, e.g. apply :set number to all open tabs?
vfclists's user avatar
  • 867
32 votes
2 answers
12k views

Why is Vim for Debian compiled without clipboard?

I'm curious as to why the default Debian package for vim (the one you normally get by sudo apt-get install vim) isn't compiled with clipboard support? Neither the regular -clipboard or -Xterm-...
Gustav Blomqvist's user avatar
32 votes
1 answer
17k views

What does z stand for in vim?

I was looking up at tips on screen shifting and came across the following tips: zz = shift current line to middle of screen zt = shift current line to top of screen zb = shift current line to bottom ...
James Franco's user avatar
  • 1,031
31 votes
7 answers
22k views

How to go to previous open buffer from Vim command line?

I am trying to write a Vim function which should make the window go to the previous open buffer. How can I do it from the command line? My first idea was to find out some CTRL-O command line ...
ephemerr's user avatar
  • 773
31 votes
2 answers
4k views

Is lookaround possible in vim's regex system?

I have encountered many situations in vim where it would be useful to have lookaround statements. I have tried using the standard lookaround syntax ((?=), (?!) etc ..), but it appears vim does not ...
EvergreenTree's user avatar
31 votes
3 answers
10k views

How can I redefine plugin key mappings?

I have installed a plugin that doesn't provide a mechanism to disable the key mappings it defines. I want to redefine one of the mappings (<leader>cc) defined by the plugin for my own pursope, I'...
toro2k's user avatar
  • 4,682
31 votes
3 answers
9k views

How to create my own autocomplete function?

How do I create my own list of auto-completion for certain filetypes? For example I would like css and html to autocomplete from the list of css classes in FontAwesome.
firedev's user avatar
  • 2,312
31 votes
4 answers
1k views

Why can ci" be outside of quoted area and ci( only works inside parentheses?

When using ci" the cursor does not have to reside in the double quoted area. |String somestring = "some text"; Assuming the pipe is the cursor position, ci" will make it jump to the quoted area. ...
Reaver's user avatar
  • 593
31 votes
4 answers
12k views

Math calculations in Vim?

I saw someone insert the result of an expression in vim, but I don't remember how it was done. For example, say I want to calculate and insert the result of 7 * 7, is there a calculator that I can use ...
Philip Kirkbride's user avatar
31 votes
4 answers
7k views

How do I deal with very long lines in text (500+ characters)?

For some text formats, line breaks matter. For example, I often use Vim to write MediaWiki documents, where you can't just put a linebreak anywhere (unlike Markdown). So I'm forced to write lines ...
Martin Tournoij's user avatar
31 votes
3 answers
6k views

Learning Vim after vimtutor

What should the next steps to learning Vim be, after completing vimtutor? I've watched videos on YouTube, read tutorials online and questions/answers on SE, and am busy reading Practical Vim. Are ...
SabreWolfy's user avatar
31 votes
2 answers
6k views

Swap function arguments

When refactoring code it would be useful to be able to swap function arguments. Changing for eg: func(foo[0], bar(), baz.spam) into func(baz.spam, foo[0], bar()) Is there some way to swap ...
ideasman42's user avatar
  • 3,613
31 votes
3 answers
13k views

Undo in insert mode

Is there a command to undo the last operation performed while in insert mode? I just pasted text from the wrong register using <C-r>, and I have two options: Delete by hand what I just pasted ...
zool's user avatar
  • 982
31 votes
2 answers
5k views

What's the difference between "quit" and "abort"?

When I try to open a file from multiple vim instances, I get an error with several options: Swap file "~/.vim/tmp/file.swp" already exists! [O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:...
Kevin's user avatar
  • 601
31 votes
5 answers
590 views

How can I treat LaTeX quotes as a text object?

Quotation marks in LaTeX are different than in normal text, in that they're formatted ``like this'' (or `like this' for single quotes). This makes it difficult to navigate through them in Vim. I ...
Doorknob's user avatar
  • 14.6k
30 votes
6 answers
14k views

How to reverse the order of lines?

How can I reverse the order of lines so that the first line appears at the end and the last line appears first? (Could be all the lines in a buffer, an address range, or a linewise visual mode ...
200_success's user avatar
  • 9,209
30 votes
8 answers
10k views

How to generate random numbers?

I would like to generate one or few random numbers separated by new line. How this can be done?
kenorb's user avatar
  • 17.7k
30 votes
5 answers
15k views

How do I close Vim externally?

Let's say I have a X11 server that's hanging, keeping me from saving the work from the XTerm Vim session that X11 server controls. (Not GVim, just regular Vim-in-XTerm.) Is there a way that I could (...
DevSolar's user avatar
  • 789
30 votes
2 answers
6k views

What is the mnemonic for Ctrl-Y (in normal mode)?

I know "expose one more line" for Ctrl-E, but why use Ctrl-Y to expose one more line at the top? Is there an easy mnemonic for this that I'm missing?
Wildcard's user avatar
  • 4,305
30 votes
7 answers
14k views

Easiest way to switch git branches

Right now I'm using fugitive to manage almost everything git related, but I can't find a good workflow to quickly visualize and switch between available branches. I can do :Git checkout <branch-...
Sergio D. Márquez's user avatar
30 votes
4 answers
11k views

How to show search results for all open buffers

One thing I often do (but rely on the command line to do) is searching/grepping in multiple files. Is there a way to display search results for all the open buffers? Ideally, I'd like to have a new ...
Roflo's user avatar
  • 757
30 votes
7 answers
28k views

How can I get Vim to show documentation of a C/C++ function?

Most editors have a feature like when you press some keys by placing caret over a function, it pops the documentation of that function along with number and type of arguments that function takes. I ...
sherelock's user avatar
  • 401
30 votes
1 answer
10k views

Understanding CTRL-U combination

In this answer I faced the CTRL-U used in function call after : and before the actual function name. :nnoremap <buffer> <cr> :<C-U>call append('.', repeat([''],v:count1))<cr> ...
user3663882's user avatar
30 votes
1 answer
7k views

How can I get both splits to scroll left or right at the same time?

I want to open up two different parts of a document in horizontal splits (using :sp) and scroll both of them left and right together. For vertical scrolling, you would use scrollbind. However, I'm not ...
Christopher Bottoms's user avatar
29 votes
6 answers
6k views

What additional features do gVim and/or MacVim offer compared to Vim inside a terminal emulator?

I'm learning Vim by watching screencasts. And I'm wondering, why do a lot of people use gVim or MacVim? From what I can see, the GUI Vim version only have additional features that involves using ...
Aaron Shen's user avatar
  • 2,439
29 votes
2 answers
3k views

How can I perform a search when vim displays content using "more" pager?

I want to see the value of a variable, so I run the command :let Vim displays the results of this command using the --more-- pager. How can I search this for a phrase, e.g. html? I've looked the ...
the_velour_fog's user avatar
29 votes
9 answers
37k views

arrow keys don't work in insert mode

When I hit the arrow keys in insert mode I get characters instead of navigation: I'd like to be able to use the arrow keys to navigate. Things I've tried I have set nocompatible in my ~/.vimrc (...
theonlygusti's user avatar
  • 2,083
29 votes
3 answers
9k views

What is the order of WinEnter, BufEnter, BufRead, Syntax, FileType events?

I've gone through the autocmd.txt help, but the information about this is scattered and not always present (eg. with BufRead). Could someone who understands this well list the order of these events -...
Sundar R's user avatar
  • 741
29 votes
6 answers
19k views

Vim Code Completion for Python 3

I am running Debian Jessie and use the current vim-nox (with +python -python3). I am having a hard time trying to program in Python 3, as I struggle with Python 3 code completion. YouCompleteMe doesn'...
xt440's user avatar
  • 351
29 votes
2 answers
14k views

How do I get Vim to be able to run both python and python3 on a Linux system in the same session?

On Linux systems, packaged Vim typically has only one of either python or python3 enabled. It is possible for both to be enabled (using python/dyn and python3/dyn), but during a session, only one can ...
muru's user avatar
  • 24.5k
29 votes
5 answers
3k views

How can I reformat a multi-line string in Vim when using the Python filetype?

Let's assume I am editing some Python code in Vim that looks a bit like: myobj.myfunc("Some string parameter that goes on and on and on and on and sometimes doesn't" "split ...
Andrew Ferrier's user avatar
28 votes
2 answers
19k views

File Type dependent key mapping

I'm trying to setup mappings for <C-]> that, depending on the buffer's file type, trigger different functions. For example, if I'm in a Javascript buffer, I want <C-]> to trigger :TernDef. ...
domi91c's user avatar
  • 469
28 votes
6 answers
6k views

How can I really have some fun in Vim? [closed]

I love Vim. I spend my whole life using it: At work I develop code with Vim, I edit config files with it, I write my emails with it. At home I write my todo lists and my buckets lists with it. On my ...
statox's user avatar
  • 48.5k
28 votes
3 answers
15k views

Can the split separator in vim be less than a full column wide?

I use a tiling window manager (awesome) + a terminal multiplexer (tmux) + splits inside of vim. I have no window decorations at all, so there is no visual split between them at all if the content of ...
Caleb's user avatar
  • 2,215

15 30 50 per page