All Questions

Filter by
Sorted by
Tagged with
0
votes
1answer
26 views

Vim session swaps files around

I create a session using :mks, which has tabs and split views inside tabs. When I open the session using vi -S Session.vim, some of the files are swapped around. I have tried deleting and creating new ...
6
votes
1answer
890 views

Visual scrolling/visual <C-e> and <C-y> across wrapped lines?

This has been asked on stackoverflow before, but it seems it still has no solution. Perhaps that has changed with Vim 8.0. I'd like to be able to scroll (i.e. scroll-wheel, or <C-y>/<C-e> ...
1
vote
1answer
52 views

How to paste text after each line matching a pattern?

I have a file like this: int var; int f() { // Use of var } int g() { // Use of var } int h() { // Use of var } // ... I want to move my global var into each function to get this ...
1
vote
1answer
31 views

Underscore suddenly a word boundary

I now have Vim version 8.1.2102 from Sep 30 2019 15:45:59 on Fedora 30. For some reason the word boundary in C++ code now also includes the underscore somehow, so I see this: When I have the cursor ...
0
votes
1answer
26 views

How can I keep the cursor position when piping the buffer through an external command?

I sometimes make shortcuts for myself, which run some external command on the current buffer, such as nnoremap <C-f> :%!clang-format -style=file<C-m> which formats the buffer with clang'...
1
vote
1answer
568 views

Do not change current directory

I want to have fixed current directory equals to the directory where vim was opened. Note I am using tabs and splits, so I want to have the same current directory in all tabs and splits. How can I do ...
1
vote
1answer
28 views

How to remap escape in *vi* (not vim)?

I've used the information in this answer previously, but recently encountered a minimal installation with only vi. I edited the .vimrc in the user's home folder (~/.vimrc), but when typing jj, the ...
4
votes
1answer
72 views

Cursor Column in Visual Selection

What is the correct way get the column of the cursor after a visual selection was made? As a simple example, consider the following command. It takes a range and I am trying to obtain the column to ...
0
votes
0answers
21 views

navigating dictionary completion

In my vimrc I have the following mappings: set completeopt=longest,menuone,preview inoremap <C-h> <C-n> inoremap <C-k> <C-p> inoremap <Leader>k <C-x><C-k&...
1
vote
0answers
13 views

Wrap matches shown by You Complete Me

Is it possible to wrap the matches shown by YCM ? My current workaround is to decrease font size till I am able to see it and then increase font size. This is tedious and painful. Is there any other ...
1
vote
1answer
21 views

Vim different colorchemes for different file, but same backgroung color

I'd like to have a colorscheme but keeping my terminal color as a background color. This code achieved that colorscheme MyFavoriteOne autocmd ColorScheme * highlight Normal ctermbg=NONE guibg=NONE I'...
2
votes
0answers
22 views

Cannot :Explore public ftp service (I see empty listing with ../ and ./)

The address is ftp://ftp.yandex.ru/ I tried from bash: vim ftp://ftp.yandex.ru/ After that I was asked for username and password (but this is public anonymous server), ok I entered anonymous for ...
1
vote
0answers
30 views

How to make “view” read vimrc?

view is the readonly mode of vim. I would like view to read the exact same .vimrc file for its initialization as vim already does. view does not seem to read ~/.vimrc by default (I checked by adding ...
0
votes
2answers
524 views

substitution in every other line

how do I search/substitute in every other line. :s/pattern1/pattern2{2}/g file looks like 1 pattern1 text 2 pattern1 text 3 pattern1 text 4 pattern1 text Output file should look like 1 pattern1 ...
1
vote
1answer
49 views

Replace Only First Occurence after Pattern

Suppose I have a file which contains: TEMP=100 TEMP=100 and I want to change all of the string beyond 'TEMP=' to 200, so it would read: TEMP=200 TEMP=200 I could use the command :%s/TEMP=\zs.*/200/...
0
votes
2answers
54 views

Find and replace only between searched patterns

Editing large HTML file. Would like to do something like: :/<blockquote>/,/<\/blockquote>/s/^\(\s\s\+\)\(<[^>].\{-}>\)/\1 \2/g So basically just trying to indent all between ...
2
votes
1answer
72 views

Named capture groups in vim regex?

Does vim allow us to assign names to capture groups for search/replace that can be used in place of \1, \2 etc... for back-references and substitution? Like in in Python: >>> import re >...
3
votes
2answers
103 views

Replace after a specific pattern

Suppose I have a string as follows: RESULT=100 How would I replace everything following 'RESULT=' so that the string reads: RESULT=200 The closest I've gotten so far is to use: :%s/\(RESULT=.*\)\@...
0
votes
1answer
20 views

Why doesn't i<Ctrl-R>=expandcmd('se shm') work?

I'm trying to do i<Ctrl-R>=expandcmd('se shm') and more generally i<Ctrl-R>=expandcmd({expr}) but I'm just getting the literal {expr} inserted. When I type :se shm<CR> I get the ...
6
votes
2answers
365 views

How to select a matched autocompletion item

I want to select the 6th item (here readImage) in the auto-completion items. The normal way i knew is pressing ctrln for 6 times until the matched word is selected and then press enter. I tried ...
13
votes
1answer
29k views

Setting TAB to 2 spaces

I've looked through various answers which imply that setting the following in .vimrc would be appropriate to force tab insertions to become spaces. filetype plugin indent on " On pressing tab, insert ...
0
votes
1answer
60 views

Using %:p when path has space in it

I have this bit of vim script: nmap <F9> :w<cr> \:execute 'silent !tmux new -ds blah'<cr> \:execute "silent !tmux send-keys -t blah '%:p' Enter"<cr> \:execute 'silent !...
-1
votes
0answers
23 views

gvim enter, space bar and escape key - <9b> [closed]

In vim 7.4.160 version , when i use Enter, Space Bar and escape keys, im getting <9b> character on my screen. kindly let me know the solution to revert it back. Thanks Suresh
0
votes
1answer
25 views

Permit closing window with unsaved changes using vim setting

I wrote a plugin that executes a slow shell script and asynchronously shows the stdout in a popup (split) window. When I try to close my session while the popup is open, I get the message Save ...
0
votes
1answer
100 views

Font on Mac Catalina

I just now upgraded to Catalina on Mac (10.15) and immediately ran into an odd font behavior: when I open a file with MacVim (8.1.1722 (157)), the letters with tails (g, y, p...) have their tails cut ...
7
votes
2answers
392 views

How to source a part of a file

I can source a file, e.g. my vimrc with :so % or :so <filename>. But what do I do when I need to source only part of a file. I want some way to visually select a portion of the file with :h v ...
0
votes
1answer
49 views

Keep indentation after multiple newlines

I've got a problem where in insert mode, if I type something like { that will cause indentation, then press enter twice, then match that bracket (such that there is a line in between the opening and ...
2
votes
1answer
24 views

ALE Error and warning highlighting gets disabled when termguicolors is enabled

I have the ALE extension installed, and would like it to highlight errors and warnings, however when :set termguicolors is enabled, the Here's a screenshot of the problem: set termguicolors ...
0
votes
0answers
19 views

Getting conflict when setting ft=txtfmt

I installed The Vim Highlighter plugin by Brett Stahlman. The plugin requires setting filetype=txtfmt. I set the option using :set ft=txtfmt but got conflicts like Level 1 map ambiguity:[bf already ...
1
vote
1answer
52 views

How to match a word not following a defined pattern?

I have the following text file: 1: This is a book. 2: Here is the book for you. 3: There are book. 4: You can read the book. 5: Is book good to read? I want to find all occurrences of book not ...
3
votes
3answers
1k views

How to show quickfix without jumping to quickfix window?

I'm writing small liniting plugin and I want to show errors in the quickfix as soon as errorfile changes. fu! OpenErrors(job_id, data, event) let l:winid = win_getid() let l:output = split(a:...
9
votes
3answers
1k views

How do I manage and remember many abbreviations in my vimrc?

I have over 500 abbreviations(iabbr, abbr) and some mappings in my vimrc file from Java, PHP, C/C++ and Latex. It is not easy to remember right away when I don't use the languages for some time. I'm ...
1
vote
1answer
52 views

Is it possible to have vim run a command every time save `:w` is invoked?

I am editting typescript now, and I'd like to be able to have it so, whenever :w is invoked, the shell runs tsc compiling my new save. This beats having to !tsc every time. Does something like this ...
0
votes
1answer
40 views

insert new bullet point in autoindent mode

with autoindent mode on, when writing a short bullet point on restructuredtext file: - item one ~ Then I press Enter, and I get: - item one ~ but I whould like to quickly by here: - ...
0
votes
0answers
25 views

netrw bug? cannot copy marked file to target

When I try to do the following on Windows 10: go to a directory, set it as the target directory using mt go to a different directory, mark a file in that directory using mf use mc to copy the file to ...
0
votes
1answer
29 views

Jump to nearest pair of brackets with %

I'm looking for a way to change the behaviour of the % key. I know by default it will move the cursor to the corresponding parenthesis or brace, but I'm wondering if I can have it jump to the nearest ...
0
votes
1answer
38 views

Bell ring on mapping <c-/>

This is the problem. I want to use in my mapping but it causes a bell to ring every time I press on it, no matter what I mapped it to. For example: nmap <c-/> y I am on nvim-qt. PS tried ...
0
votes
1answer
80 views

/usr/share/vim/vimrc taking precedence over ~/.vimrc for textwidth

Here is my ${HOME}/.vimrc : set textwidth=0 set history=100 (FWIW, inverting their order has no effect, as one would expect.) It is read by vim (:echo $MYVIMRC returns the correct path), and indeed ...
1
vote
2answers
70 views

What is the difference between loaded and unloaded buffers?

I was looking at the documentation for the 'complete' option, and I found it a bit confusing: . scan the current buffer ('wrapscan' is ignored) w scan buffers from other windows b scan other ...
2
votes
1answer
176 views

Efficient Syntax Highlighting

I am using VIM as a note taking application and have created syntax highlighting to assist with readability. See below or the repo for all the files. syntax match Timestamp /^\d\d:\d\d \d\d[/]\d\d[/]...
0
votes
0answers
22 views

Neovim highlight syntax region inside typescript tagged template literal

I am having trouble fixing a syntax plugin for Vim. I've found a bug in a plugin that has not been touched in a fair amount of time. I want to address it myself but I believe I am lacking in a lot of ...
3
votes
0answers
15 views

How to mark multiple files in netrw?

I tried using MF *.h for example to select all the files in the current directory that end with .h but this doesnt work. What are good ways to mark multiple files using netrw?
0
votes
1answer
28 views

Enable spelling in code files outside of comments

I've got the following obviously misspelled file: bla blar blar When I open it as "bla.txt" and run :setlocal spell vim rightly points out all three words as misspellings. However, if I mv the file ...
72
votes
5answers
14k views

How to join lines without producing a space?

The standard J command for joining lines replaces the newline character(s) with a space. It's useful when editing 'literature' but can be troublesome if I, say, edit a hex dump by hand if I forget to ...
1
vote
1answer
64 views

Make mapping that accepts count independent of line count

I have a mapping that looks like this: nnoremap <expr> <c-x>b ":call MyFunction(" . v:count . ")\<cr>" I also tried to instead define function with range, but the effect is the ...
0
votes
1answer
18 views

How do I open ctrlp plugin file suggestions in Insert mode?

I'm using CtrlP plugin to switch to other files in Vim by pressing Ctrl-p. But this only works in normal mode. I want to trigger it by pressing the same set of keys in insert mode as well. How can I ...
2
votes
3answers
400 views

How to create a vimrc macro using :sort?

I tried creating the following macro: search an empty line above my location go down one line shift-v find an empty line down go up one line :sort This should sort the entire section I'm pointing at....
2
votes
1answer
43 views

How to get tpope/vim-rails gf command to work with SpaceVim

I am using SpaceVim as Ruby on Rails IDE and installed the tpope/vim-rails plugin. However, the other commands like :Econtroller, :Emodel, :find, commands are working just fine but the gf command ...
30
votes
5answers
2k views

Terminal borked after invoking Vim with xargs

I've sometimes tried invoking Vim using xargs, like this: find . -name '*.java' | xargs vim … which kind of works: As Vim launches, I see the following warning flash briefly: Vim: Warning: Input ...
9
votes
3answers
5k views

What is a scratch window?

Sometimes I see a window open with name scratch. I know it is some kind of temporary buffer/window. How can I crate one? :h scratch returns nothing.

15 30 50 per page