All Questions

Filter by
Sorted by
Tagged with
109
votes
16answers
91k views

How do I delete a large block of text without counting the lines?

In vim, I often need to delete, or yank/put large blocks of text. I can count the lines of text and enter something like 50dd to delete 50 lines. But that's a bit of a pain. How can I delete this ...
110
votes
16answers
110k views

Other ways to exit Insert mode besides Escape

The primary reason I like vim over emacs is that my hand movement distance away from the home row is very low (even as a programmer). However, the one main time that I do this is leaving insert mode, ...
113
votes
4answers
142k views

Is it possible to split Vim window to view multiple files at once?

When working with multiple files, it would be very handy if we can see more than one file in the screen at once. Is there any way in Vim to split the window (horizontally or vertically) so each split ...
59
votes
6answers
54k views

How to add indentation guides/lines

In Sublime Text 2, you get vertical guides where your indentation is, like this: but in vim I obviously don't: Is there a way to show lines like that in vim? By the way, my indentation is 2 spaces. ...
27
votes
3answers
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 ...
32
votes
1answer
10k views

What are the differences between the map, noremap, abbrev and noreabbrev commands?

These commands transform one set of keystrokes to another in some way, but I am somewhat fuzzy on which one is most appropriate for some situation. In addition, there are the ! variants of them as ...
27
votes
6answers
5k 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 ...
47
votes
5answers
63k views

How can I change the indent size?

I just discovered I could indent and un-indent easily in Vi with : << and >> By default it adds a tab character. Now I'm wondering, could this be to a number of spaces via a configuration in my ...
24
votes
8answers
7k views

Is there a best practice to fold a vimrc file

I recently realized that my vimrc is now more than 400 lines long (which IMO is too much I'll try to reduce that) and to make it easier to navigate, read and edit it I decided to investigate the ...
45
votes
5answers
12k views

How to yank a line with a certain line number?

Say that I am on line 20 and I would like to yank line 4, how can I do that? And similarly, how can I yank a line relative to my cursor position, say the one 3 lines up?
49
votes
4answers
78k views

What does :set background=dark do?

I didn't put color xxx in my .vimrc. So I see this when I first open my .vimrc. :color gives me default here. Then I type :color darcula. And it changes to this. :color gives me darcula here (...
28
votes
5answers
12k 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 (...
46
votes
3answers
17k views

How to make regex matchers non-greedy?

I am trying to use a regex for replacing text in a file (replace a full url with just protocol/domain/): :%s/\(https\?:\/\/.*?\/\).*/\1/gc Unfortunately .*? does not match the string, even trying to ...
45
votes
1answer
10k views

See the Unicode code point of the current character

How can I see the Unicode code point of the character where the cursor is? For example, if my cursor is on a ⌘ character, I'd like Vim to tell me that it is U+2318. Alternative information, such as ...
33
votes
10answers
74k views

How to enable +python feature in vim

I want to install a vim plugin, this plugin needs a +python feature, so when I open vim and type :version it displays -python. How can I make it enable?. Thanks.
13
votes
1answer
10k views

How can I fix “missing” syntax highlighting for Python keywords such as “self”?

I'm trying to fix syntax highlighting for python; my colors are different from those in screenshots of what it "should" look like in different vim color schemes. And you can see the difference in ...
26
votes
6answers
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 ...
14
votes
6answers
15k views

How do I get Vim to compile my .tex file when executing :w?

My writing routine is like this: I edit a .tex file using vim I go to the command line and I compile it using pdflatex. I find myself always saving the file with :w and immediately having to switch ...
26
votes
4answers
2k 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 very" ...
24
votes
4answers
5k views

How can I make Vim open help in a vertical split?

I usually work in a drop-down terminal, running about 25 characters high. Since I prefer tabs to windows1, usually a lot of horizontal space is wasted - around half of the terminal width. On top of ...
23
votes
6answers
5k views

Set cursor colour different when on a highlighted word

With the current colourscheme I have been using, it is hard to find where the cursor is positioned when navigating through search results. The highlighting colour and the cursor colour are blending in ...
15
votes
5answers
14k views

How to replace each match with incrementing counter?

I want to search and replace each occurrence of a certain pattern with a decimal number which begins at 1 and increments by one for each match. I can find similarly worded questions that turn out not ...
14
votes
1answer
1k views

What is the difference between a tab, viewport, window, split and buffer?

What is the difference between the following in vim: buffer window viewport split tab
27
votes
7answers
8k 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?
18
votes
3answers
19k views

How can I automatically indent on new lines?

I work on projects with varying levels of indentation. In many of these projects, because of how the files are typically structured, most lines are indented at least two levels (such as methods in ...
17
votes
2answers
2k views

Expand f and t motion to next lines

Is there a way that t{char} and f{char} will continue to work in the next lines if {char} is not present in a given line? I would like to avoid using /{char}<CR> to save 1 keystroke and to not ...
14
votes
5answers
2k views

Quick search, limited to a C++ function

I work on a rather large C++ project. One of the more frustrating aspects of its organization is very large functions placed inside ridiculously large files. I often want to search for any instance ...
14
votes
2answers
2k views

How do I stop a recursive macro at the end of the line?

How can I create a recursive macro so that it only runs until the end of the line? Or how to run a recursive macro until the end of the line only?
12
votes
4answers
3k views

Vim HardMode Fine Grain Movements

I recently found out about Vim hard mode and I've decided to try and use it. However, I'm running into some problems with fine grain movements. For example, let's say I really just want to move up or ...
6
votes
2answers
8k views

Neovim setup on MS Windows

I'm trying to switch from Gvim to Neovim. Most tutorials are about Linux and not how to setup Neovim on MS Windows? Two problems: vimrc From the document it's %userprofile%\AppData\Local\nvim\init....
37
votes
4answers
7k views

How do you “chomp” a string in Vim?

Suppose you run the following piece of vimscript: let @z = system("date") This will put a string version of the current date into the z register, but the string will end with a newline that I don’t ...
36
votes
4answers
21k views

How to disable arrow keys in vim?

I want to teach myself to prefer hjkl more over the arrow keys in order to stay on the home row. (I am very aware that one should not use hjkl as the main navigation keys as there are more powerful ...
19
votes
5answers
9k views

How to find out what a key is mapped to?

I know that running :map commands without arguments should give me a list of user-defined mappings, but, for example, when I press Ctrl-W Ctrl-I something happens, yet I have no idea what function was ...
11
votes
2answers
12k views

How to toggle comments with ctrl+/? [duplicate]

I'm coming from Atom, and with that I can highlight multiple lines and hit ctrl/ and it'll toggle comments for those lines. I how easy this is. Can I do something similar using ctrl/ with vim? I don'...
11
votes
3answers
1k views

Vim, ctags and overloading

Is there a way to make vim jump to the right matching definition automatically in case of multiple definitions. Our C++ code heavily uses function overloading and vim's handling of ctags does not ...
8
votes
1answer
600 views

How to visually select based on indentation?

If someone is editing the following javascript file: let foo = true if (foo) { let bar = 42 // moooooore code... } You can use vi{ anywhere on the line with let bar to select let bar = 42 and ...
6
votes
2answers
1k views

How to map <C-i> separate from <Tab>?

I want to remap <C-I> to print markdown * symbol around the previous word. For example: # user actions inside <...> some text typed in vim insert mode<cursor_position> <C-I> #...
5
votes
3answers
408 views

Way to get content of Visual Selection?

Now if I select something in visual mode, is there some way to get the selected area without having to yank it to some register? I looked through :h functions but didn't find anything.
27
votes
2answers
7k 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'...
18
votes
1answer
2k views

How can I map d[count]d?

N.B. This is not a duplicate of How does the "d3fg" command work? Please read it before voting to close! I've come to a bit of an impasse in my quest to get small deletions work like big ...
18
votes
4answers
758 views

Can I make Vim also save “small deletions” into register "1?

I recently removed the YankRing plugin from my setup partly because it was causing some problems with macros, but mostly because I decided it would be better to train myself to use Vim's registers ...
16
votes
1answer
2k views

Show partially hidden wrapped lines

I have turned on line wrapping with set wrap linebreak nolist in my .vimrc. However, this has the annoying behavior that lines not completely visible on the screen are hidden outright and replaced ...
15
votes
1answer
993 views

How to move the cursor to the correct indentation level without quiting insert mode?

For example I have this JavaScript code. The | character represents the cursor position and it is on an empty line. function a() { console.log("a"); function b() { console....
13
votes
1answer
1k views

Can't map German 'umlaut' keys in .vimrc

I'm trying to find a way to map German umlaut keys (Ä,ä,Ö,ö,Ü,ü). A simple shortcut like this won't work: inoremap <c-ö> <Esc> Nothing happens when I hit ctrl+ö. Does anyone know a ...
12
votes
4answers
727 views

How can I safely undo changes that I may or may not have made?

Too often do I make the mistake of typing with the wrong window focused (and have done so a few times with a USB authenticator). In programs with lots of hotkeys enabled (Gmail, VLC, Vim), this often ...
12
votes
1answer
261 views

Prevent Vim from recording events for certain filetypes

To add to this stackoverflow question, what should one put in their .vimrc to ensure 'private editing' of certain file extensions (e.g. .gpg files). Without compromising the effectiveness of the ...
11
votes
3answers
5k views

Vim slows down over time with syntax on

Is there anything I can do to keep syntax on when using Vim? As soon as I open anything substantial it becomes nearly impossible to edit after a while. Every keypress causes a delay. If I turn syntax ...
11
votes
7answers
1k views

How to search for pattern in certain syntax regions?

I am using vim to edit latex documents. Often, I will want to change the name of a variable to something else. However, it's a little annoying to have to wade through irrelevant matches when I search ...
10
votes
2answers
1k views

How do I make opening new tabs the default?

When I open vim with multiple files (vim f1 f2 ...), how can I make it open them in tabs directly, without using -p? I'm looking to separate out shell behaviour from vim behaviour, removing vim-based ...
9
votes
1answer
2k views

Is there any way to distinguish between neovim and regular vim?

I was trying to migrate to neovim from vim. But in the end, there's some plugins which require python3 support and neovim package doesn't build with python3 by default( I'm on ubuntu, install neovim ...

15 30 50 per page
1 2 3
4
5
27