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 <...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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)....
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.
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 ...
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
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 ...
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()...
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 ...
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 *.
...
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 ...
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 ...
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, ...
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
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 ...
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 ...
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 ...
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> &...
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 ...
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 '"...
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 ...
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``
3
votes
Accepted
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
mark × 56vimscript × 6
search × 4
cursor-movement × 4
key-bindings × 3
neovim × 3
normal-mode × 3
cursor-motions × 3
vimrc × 2
command-line × 2
cut-copy-paste × 2
vim-windows × 2
visual-mode × 2
highlight × 2
folding × 2
navigation × 2
plugin × 2
autocmd × 1
save × 1
ex-mode × 1
tabbed-user-interface × 1
cursor × 1
tags × 1
conceal × 1
color × 1