Hot answers tagged

7

This will do it: CTRL-W ] *CTRL-W_]* *CTRL-W_CTRL-]* CTRL-W CTRL-] Split current window in two. Use identifier under cursor as a tag and jump to it in the new upper window. In Visual mode uses the Visually selected text as a tag. Make new window N high. courtesy: D. Ben Knoble


6

I do this by first creating a mark - for example, create a mark named "a" with ma in command mode – then search or move around the file however you want. Then go back to your mark with 'a.


6

I'm not aware of any Vim feature or even plugin that does that; in fact, up until recently it would be rather hard to display it like that, but with Vim 8.2's popup windows it wouldn't be too hard; you just have to loop over all visible windows and create a new popup window displaying the window number. The closest thing you can get, which may actually be ...


4

You are looking for Choosewin, sadly it's not being actively developed anymore, but for the simplest use cases it works great.


3

Two options I can think of off the top of my head: :[v]split, then search in only one window :nnoremap / mz/; then `z should take you back. Only works for one search at a time (i.e. new searches overwrite the mark)


2

With vim only There's a few options to make navigation between files less tedious in vanilla vim. First, you probably want to have set switchbuf=useopen in your vimrc (:h 'switchbuf') to reuse a split, instead of opening the buffer in the current split. If you have the buffer number in 'statusline' (i.e %n), you can then easily switch to a split by number ...


2

let's suppose I'm at the beginning of line 10 Then the easiest way back is 10G or :10. It's not that useless if you have line numbers on and your memory is not bad either. Also, sometimes the command g; (go back one position in the change list) proves to be be useful.


2

Custom operator would be a much better choice than a map, as you can use it with motion, it's very flexible. Lots of people use surround operator provided by tpope/vim-surround, it's bound to ys in normal mode and S in visual mode. If you want to surround something with asymmetric text, you can customize it like this: let g:surround_{char2nr('v')} = "\\...


2

This functionality is provided by standard "matchit" plugin (if running Vim make sure you've enabled it with packadd matchit). Press [% to get to the previous unmatched bracket. Don't forget to add < and > to :h 'matchpairs' as it's not the default. Read :h matchit for more info.


1

You can always use call searchpair('<', '', '>', 'bW') To search for arbitrary pairings.


1

One option is for you to save what the previous window was before the windo command. Then, later, jump to that window before jumping to your target window. function! MyFunction() let previous_win_id = win_getid(winnr('#')) let current_win_id = win_getid() windo ... call win_gotoid(previous_win_id) call win_gotoid(current_win_id) endfunction A ...


1

You can use a search and include \ns to match end of lines. Two of them in a row would match a blank line. You can then use \s*\S to find the first non-blank character of a line (and ensure you're matching a line with a non-blank character) and use \zs to control the start of the match (match that first non-blank character only and none of the spaces.) /\n\n\...


1

There's a much simpler solution to your specific problem of surrounding the current selection with \view; and ; delimiters. Type: c\view;;EscP c — change the visual selection: this deletes the text and enters insert mode. Crucially, it also stores the deleted text in the unnamed register, \view;;Esc — enter your delimiters and exit insert mode, ...


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