Hot answers tagged

5

I think your best bet is to use a plugin like vim-indent-object it defines some new text objects to handle indentation levels: Other alternatives are either: Creating your own text objects manually as described here which is more or less reimplementing the plugin I mentioned before Using a library like vim-textobj-user which helps you creating new text ...


3

I'm pretty sure a very similar question was already asked here. Anyway, here's a simple trick: :g/^\l/-join That is, for every line starting with lowercase letter join it with the previous one.


3

There's no history for Normal/Visual mode in Vim. The only thing I can remember of is v:operator which is set to the last Normal/Visual mode operator executed.


2

An idea: nnoremap <expr> f FindInsert('f', 'i') function FindInsert(find, insert) abort const l:char = getchar()->nr2char() return printf('%s%s%s', a:find, l:char, a:insert) endfunction It would then be easy to add F/t/T, or to use a instead of i, or what have you. But be aware that when you press ; or ,, you won't get this behavior. Also, I ...


2

This solution worked :%s/\n\([a-z]\)/ \1/g I am familiar with the %s///g format but had previously struggled, for whatever reason with putting regex into vim's search and replace command. Don't know why becasue as I now see it's as easy as any other regex substitution.


2

This is indeed a tricky one, since the column at both start and end will be the index of the first byte of a multi-byte character and subtracting them will give you a length in bytes and not in characters. The way I got to find the contents of the selection was to use strpart() twice, the first time using the start and end index to get all characters before ...


2

This works if you're in Visual Line mode, so one option (the one I'd recommend) is to always convert to Visual mode (from character or block visual mode) if needed, before the operation. With characterwise visual mode, the > command affects the line in a way that the original bounds of the selection are lost (in that they're no longer tied to the ...


1

The syntax error is happening because the function call is passing an async=True keyword argument. The async term has become a reserved keyword in recent Python, so it's not allowed as a keyword argument anymore. If you load this source code in a Python interpreter, it's quite possible that it won't complain about it right away. Python is an interpreted ...


1

If it’s always a whole line, just replace gv with V We tried xnoremap <expr> <Tab> line("'<") isnot# line("'>") ? '>gvVgv' : '>V' to handle multi-line selections and single-line selections, but there are some issues (see comments)


1

You might try making the buffer unlisted with :set nobl (see :h 'buflisted'). This is a buffer local setting so it only affects the current buffer. Unlisted buffers don't show up with :ls by default (see below). Not sure if this will work with what you have in mind for your plugin as you didn't provide a lot of details. But the basic requirement would be ...


1

Looking into the source code of gruvbox-material/gruvbox I can see: https://github.com/gruvbox-community/gruvbox/blob/9e71159ffa93be1e772d2cb3c78ee940f7b308ba/colors/gruvbox.vim#L272 g:gruvbox_termcolors == 16 fallback to use terminal 16 colors which are only viable if you have set them properly in a terminal to match gruvbox colors. I suggest to add set ...


1

I recommend using the vimtex plugin. It allows opening zathura as a PDF viewer after compiling in one step. Also it has continuous mode, meaning that you will be able to see automatically compiled changes immediately in the running zathura instance.


1

The documentation in :help has() has a pointer to the features it can check for: The {feature} argument is a string, case is ignored. See feature-list below. If you then look at :help feature-list, you'll see it mentions the three kinds of features that can be tested using has(): There are three types of features: Features that are only supported when ...


1

Unfortunately there is nothing like that. In my library plugin, I've implemented a generic feature that takes care of restoring options, variables (where restoring may means :unlet), mappings, or trigger some other actions at the end of a sequence of operations. But it's not meant to be used on the fly. It's too verbose for that. let cleanup = lh#on#exit() ...


1

In Neovim there's only one key combination not passed to the underlying terminal process. From :h terminal-input To send input, enter Terminal-mode using any command that would enter "insert mode" in a normal buffer, such as i or :startinsert. In this mode all keys except <C-\><C-N> are sent to the underlying program. Use <C-\><C-N>...


Only top voted, non community-wiki answers of a minimum length are eligible