All Questions

Filter by
Sorted by
Tagged with
19
votes
2answers
2k views

Replace a string without changing case?

Due to a quirk in the domain-specific language I am working with, I frequently face the task of (selectively, not globally) replacing term or TERM with word or WORD, respectively. This means, I ...
9
votes
1answer
5k views

Define custom commands for the * and + registers

If I'm using a build of Vim with the xterm_clipboard feature then the system clipboard content is available through the + register. If the build I'm using doesn't have this feature, can I make the "+ ...
7
votes
2answers
537 views

Align a block of code on the basis of a single character

The question's title might sound a little vague, so I'll explain the situation here more clearly. I have these lines of code in a file which I want to align with respect to the character =. const ...
17
votes
1answer
315 views

Prevent Vim from breaking up links mid-tag in markdown

Let's say I have this Markdown file: [Lorem ipsum dolor sit ](http://vi.stackexchange.com/many-links-are-often-very) Lookin' good. But the link isn't finished it, so I type -long, and now Vim breaks ...
15
votes
7answers
4k views

How to left-align two columns of text? [duplicate]

If I have a text file like this: alpha: 1 beta: 2 gamma: 3 delta: 4 epsilon: 5 Is there a way to align the numbers like so?: alpha: 1 beta: 2 gamma: 3 delta: 4 epsilon: 5
11
votes
2answers
691 views

Scrolling issues when the `wrap` option is set

I find myself dealing with this issue every time the wrap option is active (in my particular case whenever I'm working with markdown files). What happens is that, while scrolling up and down the ...
10
votes
2answers
1k views

How do I prevent Vim from unindenting empty lines?

Vim keeps unindenting the lines I want to keep indented if I don't write anything on them... I'll give an example, where the | is the caret. Caret is indented and I press enter if expression: ...
5
votes
1answer
2k views

How to map shortcut to double square brackets?

When I type [[ or ]] in normal mode, cursor is jumping previous / next "class definition" during editing python (.py) file. I want to map these shortcuts to SHIFT + UP and SHIFT + DOWN. And I added ...
3
votes
1answer
2k views

How to load plugins from my vimrc and from another file?

I have my dotfiles synchronized on github which is a current practice. As I use several machines I want to be able to have some part of my configuration not synched on my github repo. To do so I ...
3
votes
1answer
951 views

Vim never shows line number for Python files even though I have `.vimrc`

I found it strange that I can never have Vim show line number automatically for .py files, even if I have this as my ~/.vimrc set background=dark autocmd FileType py,c set number Strangely enough, ...
2
votes
2answers
444 views

Using `TabEnter` and `FileType` in the same `autocmd`

I would like to set set spell whenever I open a tex file. My first attempt is autocmd FileType tex setlocal spell I am using setlocal here because I may open other files in new tabs after opening a ...
190
votes
11answers
119k views

How can I see the full path of the current file?

When I'm editing a file in Vim, is there a command to see the path of the current file? Sometimes this is very handy if there are multiple files with the same name in a project.
49
votes
2answers
16k 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 ...
66
votes
8answers
43k views

Fastest way to switch to a buffer in vim?

One way to select a buffer in vim could be to browse the buffers list, using standard commands as :ls, or with some external plugin / vimscript code to browse a list in a window. Let's say I want to ...
116
votes
5answers
128k views

How to replace tabs with spaces?

Is it possible to convert tabs to spaces, while maintaining text alignment? Simply replacing only works usefully when there are no leading characters.
59
votes
3answers
21k 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 ...
40
votes
5answers
13k 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 ...
84
votes
9answers
53k 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 ...
44
votes
5answers
16k views

Can Vim interpret terminal color escape codes?

Many CLI programs output nicely-highlighted text. While most of them check if the output is going to a file, some include the terminal escape codes. I like the output with the escape codes, but ...
28
votes
5answers
7k 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 ...
17
votes
1answer
2k views

Are Vim's regex magics compatible with well-known regex classes?

Many Unix tools' regular expression syntaxes are often the POSIX-codified Basic and Extended Regular Expressions (BRE and ERE, respectively), and, in some modern implementations, Perl-style (PCRE ...
33
votes
4answers
7k views

How can I make Vim autoread a file while it doesn't have focus?

I'm using VIm for all kinds of things (or gVim in this case), including monitoring output written to a file; I use autoread to make Vim reread the file, which it does whenever I switch the keyboard ...
15
votes
7answers
3k views

How to bind a set of buffers to a tab?

When I need to work on different projects at the same time I have the folowing workflow: I create one tab for each project. In each tab I open the files that I want to edit, which makes several ...
12
votes
2answers
2k views

Cut vim load time

I'm using https://github.com/carlhuda/janus vim distribution and clearly not satisfied with load time. What would be the best way to profile and speed-up vim load time? Also would be interesting to ...
30
votes
5answers
2k 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 ...
21
votes
2answers
6k 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 -...
15
votes
3answers
1k views

How do I visually select the block of text I just pasted in Vim?

I usually need to move/copy code snippets between my source files. After I paste a block of text, I usually need to apply some operation to that block such as reindenting them with =. Is there a way ...
7
votes
4answers
3k views

How to convert all windows into horizontal, vertical or tab splits?

It is possible to convert all windows into different split mode while editing? Instead of one by one? In example (having multiple windows) from horizontal to vertical split and opposite, or from tab ...
24
votes
3answers
8k views

What does `<Bar>` mean?

In answering a question just now, I mentioned using a normal mode key mapping that can be found at the Vim Tips Wiki. In the middle of explaining the key mapping, I realized that I had no idea what &...
20
votes
2answers
3k views

What does :open do in vim?

Vim's documentation has this to say about the :open command: This command is in Vi, but Vim only simulates it: *:o* *:op* *:open* :[range]o[...
9
votes
3answers
3k views

How do I add skeleton text to new vim files?

I use Vim for writing C++, and I have quite a few #include<> statements, comments, etc. that I must include in each new file I create. I've added autocmd BufNewFile *.cpp r C:\(full file path ...
25
votes
5answers
968 views

How can a complete beginner learn Vim using just Vim itself?

As a complete beginner with no vi experience, how can I learn to use Vim using just Vim itself? Is there a built-in tutorial, and how can I access it? Assume I have a laptop with Linux and Vim ...
20
votes
2answers
350 views

Why does "Operator" + "Motion" behave inconsistently?

This is something that has bugged me for a long time, but I've never gotten around to asking about. Say the text in your buffer looks like this: Hello World If I put my cursor somewhere in line 2, ...
18
votes
3answers
459 views

Speed bump on <Esc>O (Insert to Normal to Insert new line above cursor)

Often when I'm in Insert mode, I'll hit Esc to get into Normal mode, and then immediately hit O to begin a new line above the cursor and go into Insert mode there. But when I do that, there is a 1-...
11
votes
2answers
7k views

Showing command history with showcmd

When using set showcmd Vim shows partial commands in the last line of the screen. For example, in Normal mode when typing the command dt. the last line shows dt and then, when you hit . the command is ...
6
votes
1answer
1k views

What's t_TE and t_TI added by vim 8?

First let me show a screenshot below. In the modeline, a strange sequence of characters(>4;m<ESC>[>4;m<ESC) is shown. And not only in the modeline, I have seen such similar sentence in ...
4
votes
1answer
885 views

recover default behavior of arrow keys rather than having them produce ABCD, when I map <esc>

My question is related to this post which for some reason was closed. Here's my .vimrc file set cpoptions=BceFs$ ":compatibility flags with /usr/ucb/vi set hlsearch hi Search ctermfg=white ...
3
votes
1answer
293 views

Vim on Debian, configuration issues

I have been working with a stock vim configuration for a long time. I want to modify just a couple of settings. I don't want to lose the rest of the default configuration. If I create a new .vimrc I ...
9
votes
6answers
7k views

How can I copy/paste new text without auto-indentation at every new line?

How I paste now: Right-click/Copy or simply highlight. Right-click/Paste or Middle Click or CTRL+SHFT+V Indents appear at increasing intervals: 0, 2, 4, 6, + Question at hand: From prior research, ...
4
votes
2answers
522 views

Why do exclamation ! shell commands in GVIM show error: "syntax error near unexpected token (" for "ls() ("?

E.g., it I do: !echo a or any other !, it first prints: syntax error near unexpected token ( ls() ( /* my alias */ ) and then the actual command. The problem only happens in GVIM, not in Vim. ...
4
votes
1answer
195 views

Autocmd treat user defined command differently?

This works fine: augroup au_test | au! autocmd BufNew * if 1 | echom 123 | endif augroup end But this doesn't work: com Test echom 123 augroup au_test | au! autocmd BufNew * if 1 | Test | endif ...
169
votes
9answers
61k views

Does Ex mode have any practical use?

Vim has an Ex mode that can be entered by entering Q, and a command line mode that can be entered with q:. A common complaint amongst new vim users is that they enter these modes accidentally when ...
175
votes
8answers
200k views

Displaying tabs as characters

When I work on files in python, I sometimes mistake tabs for spaces and vice versa. Is there a way I can get Vim to display a character for a tab instead of a tab?
94
votes
10answers
128k views

How can I clear word highlighting in the current document (e.g. such as after searching for a word)?

When you search for a word in a file with something like /console.log, all of the instances of console.log are highlighted. When you're no longer interested in these, the highlighting can be ...
62
votes
5answers
24k views

Vim search replace all files in current (project) folder

One of the open questions I have about Vim is if there is a way to perform a search/replace in the current project (bear with me if I use this notion inherited from other editors). For instance, let'...
106
votes
7answers
68k views

Is there a way to count the number of occurrences of a word in a file?

Is it possible to count how many times a word or a pattern appears in a file? This is sometimes useful to find out how many times a function has been called, etc.
68
votes
4answers
55k views

How can I set up a ruler at a specific column?

When coding in different languages, I tend to need to restrict my lines to a specific length (usually 79 or 80 characters). I've seen this done in other editors through the use of a ruler (solid line ...
47
votes
2answers
9k views

How do I make Vim adapt to the current indenting style of the file I'm editing?

I work on a range of JavaScript projects. In most of these projects, the indentation of JavaScript files is 2 spaces, so I've set my default indentation width to that. However it becomes 1 or 4 in ...
40
votes
5answers
14k views

Dump the output of internal vim command into buffer

How do I dump an internal vim command (not shell command) into a new buffer? For example, I want to dump a listing of all plugins into :enew from :scriptnames so that I can search it.
48
votes
1answer
13k views

How can I use the undofile?

The last news item on vim.org talks about using the 'undofile' to save your history and undo changes even after a reboot: A feature I enjoy using myself is not known to many users, as I found out ...

15 30 50 per page
1
2
3 4 5
28