All Questions

Filter by
Sorted by
Tagged with
7
votes
2answers
1k views

Can I make Vim's spell check not syntax-aware, and check everything?

The Vim spell checker is code-aware; it uses the syntax file to disable spell checking for the parts where it usually doesn't make any sense. However, on occasion I do want to spell-check this. ...
15
votes
2answers
2k views

Is cpo&vim a special syntax?

In scripts it is customary to do something like: let s:save_cpo = &cpo set cpo&vim ... script ... let &cpo = s:save_cpo To ensure nocompatible mode for the script. Is: set cpo&...
15
votes
5answers
653 views

Can I be notified when I'm undoing changes from the undofile?

I've been using the undofile feature in Vim for a while now. It's a very nice feature. However, one annoyance is that it's very easy to accidentally undo changes that I did the last time I opened the ...
16
votes
5answers
2k views

How can I open multiple tabs at once?

If I use: :tabedit file1 file2 I get: E172: Only one file name allowed Is there any way to use :tabedit with multiple file names? Or another way to open multiple tabs at once?
26
votes
6answers
9k 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 ...
5
votes
1answer
3k views

How to change last occurrence of the string in the line? [duplicate]

I've the following example line: aa ... abc abc abc ... zz I'm aware that :s/abc/ok/ will change the first occurrence of abc in the current line and adding g flag will change all of them. How do I ...
4
votes
3answers
2k views

How do I switch around 2 pieces of text?

I have 2 pieces of text, what is a proper way to switch those pieces of text. around e.g. I have this: This is one piece of text. Here is another sentence. And I want to switch around the 3 first ...
8
votes
2answers
5k views

How to make vimrc settings applicable for a directory tree only [duplicate]

Is there a way to make certain vimrc configuration valid only for files under a defined directory tree? Or alternatively, is there a way to have a .vimrc file in a directory, and make its setting ...
3
votes
0answers
200 views

Using folding with plain text? [closed]

Is there a good way to use folding with "plain text" files? But what do I mean by "plain text"? I'm thinking of text like it is used in human communication when no formal structure is required. It ...
28
votes
1answer
8k 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 ...
8
votes
2answers
250 views

How to access recently used files by choosing from a list?

I would like to have a keystroke to show a list of recently used files to choose one to edit. What do I need to provide that? And related, How do I manage the history of recently used files ...
3
votes
1answer
439 views

Is there a way to hook ctag changes to git branch checkouts and pulls?

When I checkout different branches, I sometimes notice that files in the repo are not available to Vim plugins that search based on the ctags index. I don't have a definitive test that's shown the ...
13
votes
2answers
1k views

How to escape a whole string in a : command?

Let's see. I have a gvim running and I want open a file, respecting the autocmds (which rules out --remote-tab). Now I know I can do (basically, with some tweak): gvim --remote-send ":tabe my_file&...
1
vote
1answer
1k views

How to replace URL resource path with regex?

I am trying to write a regular expression that will match a link-attribute in .png files. Example: I have a lot of .png like this https://jnTb6EZom8c/s144/800px-s%25252Ct%252529%2520%25282%2529.png ...
33
votes
2answers
9k views

What's the difference between let and set?

I don't know much of the theory behind Vim. It looks as if we set some variables, and let other variables. What's the difference, and when is one required over the other? Also, the solarized vim ...
5
votes
2answers
1k views

How can I copy the current file and start editing the copy instead of the current file?

Say I'm editing file foo. I want to copy/write what I have in the buffer to bar and change the buffer to be editing bar instead of foo. I can achieve this with: :w bar :e bar But that has a few ...
5
votes
1answer
756 views

Including dictionary terms with spaces

We can use dictionaries to help us complete keywords. To set a new dictionary you can use set dictionary+=path/to/dict. This way you will be able to complete from a dictionary by typing <C-x><...
5
votes
1answer
204 views

Different autocmd behavior when using --remote-tab-silent?

This question is a follow-up to Switching to the local directory after loading a file? I have the following in my .vimrc: autocmd BufReadPost *.tex lchdir %:p:h with the intent of setting the ...
19
votes
1answer
6k views

How do I get +clipboard support in Fedora 20?

It seems to me that neither "+p nor "*p works for me. How can I know if my Vim is installed and set up properly to make them available? And if it's not set up, what can I do to set it up? I'm running ...
6
votes
3answers
963 views

Switching to the local directory after loading a file?

When running gvim by double clicking with a file in a graphical file manager, like nautilus, the vim instance is called with a strange current directory (seems root sometime, but I am not sure). This ...
46
votes
2answers
14k views

What are the differences between LaTeX plugins?

There are a number of Tex plugins for vim (vim-latex, AutomaticLatexPlugin to say a couple). What are the differences in the provided functionalities between these (the ones I named and possibly ...
59
votes
4answers
41k views

How can I integrate gdb with Vim?

Instead of gdbtui or ctrl+x under gdb which shows source code on top of the screen I would like to see this in my Vim editor that would jump between tabs, and buffers accordingly. How can I do this?
14
votes
3answers
8k views

Can I undo multiple times in nvi and/or the original vi?

Sometimes I'm on a system without Vim, and use the default nvi (BSD systems) or the original vi (Arch Linux). There are quite a few differences, but the largest annoyance is that I can undo only my ...
32
votes
2answers
24k views

How to block replace code in visual mode?

I have a list of items where I want to replace the first two characters: a) item 1 b) item 2 c) item 3 What is the fastest way to make this: * item 1 * item 2 * item 3 I have an approach with ...
5
votes
2answers
971 views

How to change all numbers in file into float format

I have a file containing nothing but integers and words, separated by arbitrary numbers of spaces, along the following lines: 1 alpha plural 1 0 6 1440 3 1 4 1 5 9 2 6 5 3 5 8 9 2 7 1 8 2 8 1 8 2 ...
3
votes
0answers
148 views

How can I work around the inability to save macros in ViEmu? [closed]

I would like to be able to save my ViEmu macros between sessions of Visual Studio 2013. This feature was requested in 2010 and apparently almost made the cut for ViEmu 2.5: I was wondering if ...
6
votes
4answers
18k views

How do I copy and paste between two vim instances - shared clipboard?

I use gnu screen and I run vim file1.txt and vim file2.txt in two windows. How can I copy part of the text from file1.txt and paste it to file2.txt without using temporary files or opening two files ...
5
votes
1answer
1k views

How do I parse URL's from the text

I have a multiline text file. Some lines have URL's. What would be the most efficient way to extract those URL's? I wrote macros and did a bunch of unnecessary things. Now I'm thinking about regex ...
3
votes
2answers
596 views

How can I automatically execute normal mode keystrokes with a terminal command when opening Vim?

How do I run vim with file.txt and screen center at line 100? Basically I would like to use zz mapping when starting Vim. This does not work: vim -c "zz" file.txt +100
13
votes
9answers
27k views

Colorscheme's background not correct in terminal

I imported the solarized colorscheme and palette. My terminal has the correct colors and background, gvim has the correct colors and background, but vim has an incorrectly colored background. The text ...
10
votes
5answers
2k views

How do I make vim look in a set of directories for a file, if it doesn't exist in the current directory?

When I want to edit my zshrc, I just type: vim .zshrc Without specifying the full path (~/.zshrc), if I am in a different directory, this will instead start a new file. This is very annoying, since ...
9
votes
2answers
617 views

Is there a way to alias `:w'` to `:w`, to avoid creating files named '?

Occasionally, my pinky will graze the ' key while reaching for enter, resulting in :w'<Enter>. I've tried: cabbrev w' :w cabbrev w\' :w cabbrev "w'" :w None of them work. Is there a way to ...
10
votes
1answer
1k views

Apply normal mode command to regex matches

I am using the following regular expression to match a documentation string underneath a Clojure function definition: \vdefn.*\n\s*\zs"([^"]|\n)*" Is there a way to run the normal mode gq (format ...
85
votes
7answers
20k views

How do I debug my vimrc file?

I have a problem in Vim, and I think it may be in my vimrc file (or have been told it could be my vimrc file). How do I verify this? If it is my vimrc file, how do I know where exactly the problem ...
87
votes
6answers
16k views

How do I jump to the location of my last edit?

I often make changes to the middle of a big file, use gg to jump to the top to check something, and then realize I forgot to set a mark where I was editing. Is there a built-in way to jump to the ...
3
votes
1answer
10k views

Regex to search double quoted strings on multiple lines

I am trying to write a regular expression that will match all double quoted strings across newlines. I have been fiddling around with the following pattern but it seems to only match strings on the ...
14
votes
2answers
257 views

Automatically add a closing " or ' when inserting one, but only if the cursor isn't inside a string already

I've defined mappings in my vimrc to automatically enter close parentheses and braces when I enter opening ones with inoremap ( ()<esc>i. I'd like to do the same for " and ', but only when the ...
4
votes
2answers
2k views

How can I get vim to not auto-wrap pasted text? [duplicate]

I am pasting several lines of text into vim at once (from another application, so I am using the OS's copy and paste and insert mode in vim). The longest of these lines is below: " :PluginClean -...
57
votes
3answers
18k views

How can I get vim to stop putting comments in front of new lines?

I'm editing my .vimrc file, and I am including comments. When I have a comment like this: " example comment And then hit enter at the end of the line after finishing the comment, the next line is ...
10
votes
2answers
396 views

Most efficient way to replace the entire buffer?

Currently, I have two similar methods to replace the entire buffer with some other text (say in clipboard). Method #1: delete all lines: :%d. paste text: "+P ( or similar: :put+). Method #2: ...
17
votes
4answers
21k views

Can I jump to a function declaration or definition in a multiple C++ source files project?

Can I jump to a function declaration or definition in a multiple C++ source files project? Lets say I have a header file foo.hpp: int bar(); and a source file foo.cpp: #include "foo.hpp" int bar() ...
41
votes
2answers
11k views

Close all split files, except the one currently focused?

Sometimes when I'm working on a file, I'll open up multiple files just to get an idea of the current flow of the code up to a point. However this sometimes leads to multiple files being open at a time ...
12
votes
3answers
6k views

Is it possible to have the output of a :! command in a split rather than the whole window?

If I have a vim session with two splits, when I execute a :! command, the result is shown in the entire window. Is it possible to have the output shown just on the active split?
0
votes
1answer
197 views

Can I replace Vim's syntax highlighting with my own script?

Is there any way to replace Vim's syntax highlighting? For example, I now have this test script to make everything between quotes red: #!/usr/bin/env python import re, sys print(re.sub(r'"(.*?)"', r'...
75
votes
9answers
42k views

How to execute shell commands silently?

:!<command> can be used to execute a command in the shell. But this "takes over" my terminal and fills it with stdout of that particular command. How do I execute a command in the background ...
15
votes
4answers
8k views

How do I get gvim to start maximised in Windows?

I'd like to have my editors give me as much screen real estate as possible since it increases my ability to see most of the code at once. The problem is that gvim seems to give me either an 80x25 ...
4
votes
2answers
500 views

Can relative number be changed so that current line is 1?

I knew this site would teach me more about my beloved vim :-) In posting a question/answer on how to delete large blocks without having to count lines, one of the answers taught me something I didn't ...
32
votes
4answers
8k views

How to replace only within visual selection?

How does one get vim to replace a character within the visual selection only and not elsewhere on the line? Example: Line: int arr[] = { 00 01 02 03 04 05 05 /* ... lots more like this*/}; Visual ...
21
votes
1answer
204 views

How does :g/^$/,/./-j (reduce multiple blank lines to a single blank) work in vim?

In the article, Vim Regular Expressions, Oleg Raisky gives the following command to reduce multiple blank lines to a single blank: :g/^$/,/./-j Can someone please describe how this works? I know :...
101
votes
16answers
78k 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 ...

15 30 50 per page
1
188 189
190
191 192
196