Hot answers tagged

16 votes
Accepted

Is it possible to have Vim displaying the list of available marks when using marks?

You can define a very simple custom mapping that lists the available marks and pre-populates the command-line with the right command stub, ready for you to type the desired mark name: nnoremap <...
romainl's user avatar
  • 39.1k
13 votes
Accepted

What does `1 do?

You can jump to numbered marks, but you can't set them directly. According to :h mark-motions: Numbered marks '0 to '9 are quite different. They can not be set directly. They are only present ...
Sato Katsura's user avatar
  • 3,999
12 votes

How to search for lines matching current line in vim

Especially for mapping purposes, I find using getline() more elegant than doing the yanking yourself. Calling getline() with a string '.' returns the line under the cursor. There are two good options ...
Sakari Cajanus's user avatar
7 votes

How do I delete a mark in current line?

I'm going to swim against the stream on this one. Just don't worry about it. Marks are pretty ephemeral and there are bunch of marks Vim automatically maintains like '[, '', and '. Humans are ...
Peter Rincker's user avatar
7 votes
Accepted

How to search for lines matching current line in vim

Here's how I'd do it: Yank the line (into the unnamed register), without including the newline at the end: 0y$ Initiate a very nomagic search: /\V Add the yanked line: <c-r>" Fire off the ...
Rich's user avatar
  • 31.3k
7 votes

How to search for lines matching current line in vim

The existing answers all fail if your line contains certain items that are interpreted as a part of a pattern. The \V point gets most of the way there but still messes up with the backslash. Try this ...
dash-tom-bang's user avatar
7 votes
Accepted

Can I get a visual indicator when I drop a mark?

Is there a plugin or something for that that works well? Why yes there is! I use kshenoy/vim-signature, and highly recommend it. From the README: vim-signature is a plugin to place, toggle and ...
DJMcMayhem's user avatar
  • 17.4k
6 votes
Accepted

Compute the distance between two marks

You could use this function to do what you want: It takes 3 arguments: A normal mode command (which should move the cursor) The mark where to beginning the motions The destination mark It will ...
statox's user avatar
  • 49.3k
6 votes
Accepted

How to set incremental marks?

There is nothing built in to vim, but you can script something like this: fu! s:IncrementalMark() abort let b:index_mark=get(b:, 'index_mark', -1)+1 " configure, which marks to use let ...
Christian Brabandt's user avatar
6 votes
Accepted

marks with fullline visualization

I created a plugin that I think does what you want. If you want to change the colors that it uses simply define g:highlightMarks_colors in your vimrc as a list of colors (either names or RGB strings)....
Tumbler41's user avatar
  • 7,706
6 votes

Jump back to the position I started a search

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.
Kaan's user avatar
  • 331
6 votes
Accepted

How to move marked line to current location

The format for :m[ove] is :[range]m[ove] {address} Where the range is the line or lines you want to move and the address is the target. Note that the moved line(s) will actually be placed on the line ...
B Layer's user avatar
  • 19.5k
5 votes
Accepted

Find only between marks

You can use \%>'m and \%<'m to match after and before a given mark, m. /\%>'afoo\%<'b For more helps see: :h /\%'m
Peter Rincker's user avatar
5 votes

Is it possible to have Vim displaying the list of available marks when using marks?

A variation on your own response is to install fzf.vim and then bind to :Marks, e.g.: nnoremap ` :Marks<CR> This has the benefit that it will show up in fzf's fuzzy search window. (Caveat: It ...
steinar's user avatar
  • 151
5 votes

Is it possible to have Vim displaying the list of available marks when using marks?

This does exactly what my original question was """""""""""""""""""""""""""" " Ranger style marks command " """""""""""""""""""""""""""" function! Marks() marks echo('Mark: ') " getchar()...
the_velour_fog's user avatar
5 votes
Accepted

difference between marks and tags?

Both specify certain points in a file and give you commands to jump there and as such they are the same. But marks are created by vim. Either explicitly by hand with m or automatically by vim (for ...
Lucas's user avatar
  • 1,599
4 votes

How to search for lines matching current line in vim

Personally I would get a visual star plugin (there are few out there). There is a nice Vimcast about this: Search for the selected text. This means you can select the line visually and then press *. ...
Peter Rincker's user avatar
4 votes
Accepted

Go to the last cursor position using marks

The mark " indicates the position of the cursor when you last exited a buffer. Using that... Continue to use your cross-file marks but immediately follow with '" (or `" to restore the column as well ...
B Layer's user avatar
  • 19.5k
4 votes
Accepted

Jump to where insert mode was entered?

If you haven't yanked or changed text since your last insertion, then you can use the `[ mark (see docs), which gets you back "to the first character of the previously changed or yanked text." By the ...
filbranden's user avatar
  • 28.4k
4 votes

Is it possible to place marks at the end of a line?

I found the answer here. Another easy way is to just add v right after y, no setting or Visual mode selection necessary. `a"ryv`b y`b yanks to mark b excluding the character under mark b, ...
alligator's user avatar
4 votes
Accepted

Is it possible to list only my marks?

You can define a custom command like this, that will only show the lowercase marks a-z: :com :MyMarks :sil! marks abcdefghijklmnopqrstuvwxyz
Christian Brabandt's user avatar
3 votes

How do I delete a mark in current line?

To delete a mark you can use :delmark it can be shortened to :delm. If you really want something shorter you can map a function which asks for an input but it's not really a common practice to have a ...
fievel's user avatar
  • 383
3 votes
Accepted

how to remap backtick mark with single-quote mark globally

You used nnoremap which means the mapping will only work in normal mode. d and y leave you in operator pending mode. Adding the following should solve these cases: onoremap ' ` onoremap ` ' I'm not ...
Octaviour's user avatar
  • 942
3 votes

Shortcut for applying a command between the last two marks

Using 2 marks to operate on the text between those lines is the 'vi'-compatible way of the more modern and (literally) visual way of operating in Vim (and probably why visual mode was invented in the ...
VanLaser's user avatar
  • 9,620
3 votes

How to set incremental marks?

I'm not sure I understood what you wanted. But if you want to cycle through all the available local marks from a to z, then the following mapping should allow you to do so: nnoremap <silent> &...
saginaw's user avatar
  • 6,706
3 votes

Jump back to the position I started a search

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 ...
D. Ben Knoble's user avatar
  • 25.3k
3 votes
Accepted

Understanding a few of the preset marks

The marks 0-9 are the last 10 files you were editing. See :h viminfo-file-marks (took me a while to find the correct help subject). '" : the cursor position when last exiting the current buffer (:h '"...
Ralf's user avatar
  • 9,097
3 votes
Accepted

Efficient copy->paste onto mark

The ex commands :put and :delete both allow you to specify a line, so if you've already placed mark 'a on the line you want replaced, then you can execute the following after the copy: :'apu :'ad or ...
Rich's user avatar
  • 31.3k
3 votes

Efficient copy->paste onto mark

Alternative solution: If you want to replace the text at the mark, you could just use :norm!'aVp`` Or in one line with the copy: :'<,'>y | norm!'aVp``
B.G.'s user avatar
  • 1,116
3 votes
Accepted

Visually selecting from mark to cursor

It should work as shown below: v`a
ENRIQUE GARCIA's user avatar

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