Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [cursor-motions]

Commands that moves the cursor. A motion command is used after an operator command to move over the text that is to be operated upon.

1
vote
1answer
48 views

Is there a text object or motion for non-comment lines are not separated from comment lines by blank lines? E.g., in git commit messages

Consider the text A B # C # D Is there a text object or motion that will select lines A and B if the cursor is on either, but not select lines C and D? ap or ip with the cursor on any of those four ...
1
vote
0answers
24 views

How can I prevent <CR> from moving the cursor downward? [duplicate]

In the vim help doc, it says: *CTRL-M* *<CR>* [count] lines downward, on the first non-blank character |linewise|. That is, in the normal mode, <CR> has the same ...
0
votes
1answer
30 views

How to move a line onto the end of some other line

For example suppose i have 1 the cat jumps 2 over the moon I would like the result 1 the cat jumps over the moon In general how can I move line X onto the end of line Y. A solution that would ...
1
vote
2answers
45 views

Delete entire block, with the prefixes before the opening {

My problem Consider a code block prefixed with a few words (function name, for example). The vim cursor is in the middle of the prefix word. The line ends with a {, which declares a block which spans ...
2
votes
1answer
44 views

change inner backslashed quotes

I know the ci" motion and others :changes, but I need something like a ci\" in order to change inner a backslashed quotes. Assuming * as the cursor position: a = "message says: \"fo*o bar\"" I would ...
1
vote
1answer
29 views

Unable to set iskeyword for colon ( : ) character

I am using vim to edit LaTeX files. Throughout the text, there are labels to equations, tables etc. for which an accepted convention among TeX writers is the following \label{eq:massenergy} , \...
0
votes
0answers
20 views

Why does MacVim show `@` and blank space for long strings? [duplicate]

This drives me really insane... Say I have a short line of text on line 32, and a very long string on line 33, say 10,000 characters long... if I have word-wrap on, it ONLY shows line 32 and stops ...
1
vote
2answers
42 views

Changing content within the specified [count] number of braces for each line

I need to change the content within a [count] number of braces for each line in my buffer. 1 {Lorem} ipsum dolor {amet} blah blah {change this text} more blah blah 2 Hello. The {sun} rises in {the} ...
0
votes
1answer
34 views

`0` only moving to first “visible” column

I have a strange trouble with vim (8.0.95). My format options are fo=cq and nowrap. When I have a long line, which does not fit my terminal window, the view of the file does not include the first ...
0
votes
1answer
32 views

Delete from the next character till EOL

My problem Consider the following line: I have just pasted @SrvrlessDaysTLVtlv before tlv@serverlessdays.io, and I'd like to delete anything from the small-case t till EOL. What have I tried d$ ...
0
votes
1answer
64 views

Jump to next semicolun

I can use fd to jump to the next d character. How can I jump to the next semicolun? f; doesn't seem to work. Also, for other special symbols. Thanks
2
votes
3answers
74 views

How to indent one line multiple times?

Like doing >> but 5 times >>>>>>>>>>>>. I am not trying to indent multiple lines.
4
votes
4answers
113 views

Delete with search motion in normal command

I am attempting to delete from start of line until string foo. In normal mode, 0d/foo accomplishes this. Now, I would like to do this for every line in my buffer. Reading documentation and SO it ...
3
votes
2answers
375 views

Why does “e” move you one character before the actual end of the word?

Maybe it was discussed many times (I strongly believe), but I could not formulate my question properly. So lets imagine we have this sequence of words: foo bar baz Applying 3e will move us onto: ...
0
votes
1answer
26 views

How to replace ) by <left> when closing bracket [config]

I have the following in my .vimrc, it permits to automatically close brackets. ino " ""<left> ino ( ()<left> ino ' ''<left> ino [ []<left> ino { {}<left> What I would ...
0
votes
1answer
48 views

Enable %-key jumping/highlighting for backticks (`) and single-quotes (') in M4 files

Background When working on .c and .h files, I have a couple options turned on, namely: filetype plugin on filetype indent on autocmd BufEnter *.c setlocal tabstop=8 shiftwidth=8 softtabstop=8 ...
0
votes
3answers
46 views

mystery cursor motion

I hope someone can riddle me this one: I have set up the function below to have a slightly more fancy behavior of the End key, moving first to the end of the line, but if the cursor is already at the ...
0
votes
2answers
67 views

Simple modification of behavior of Home, End keys

I'm completely new to Vim scripting, so forgive me if this may seem trivial, but I would like to modify the Behavior of the Home and End keys such that, if the cursor is somewhere between the first ...
0
votes
2answers
81 views

How to make f{char} case insensitive?

Regarding this command: f{char} To [count]'th occurrence of {char} to the right. The cursor is placed on {char} |inclusive|. {char} ...
1
vote
2answers
64 views

How to change f{char} to search left if no char was found searching right?

Regarding this command: f{char} To [count]'th occurrence of {char} to the right. The cursor is placed on {char} |inclusive|. {char} ...
1
vote
1answer
41 views

Key binding to select the current paragraph

I'm using the following key binding to visually select the current paragraph. nnoremap <leader>v }kV{j Is works as follows: } Move below the current paragraph. k Move one line up. V Start ...
1
vote
2answers
59 views

How to select/delete/yank the contents of only the current fold?

When using foldmethod=marker, how do you select or reference exactly the contents of the current fold? I want to swap the order of two folds. If they were paragraphs, I would do dap { p. However, I ...
1
vote
2answers
148 views

Move to the first/last non-whitespace character of the column (“vertical W/B/E”)

For instance move from (the cursor is on the letter in bold italic, in the second column) blablabla blablabla blablabla blablabla bla bla bla bLablabla l@st to blablabla blablabla blablabla ...
4
votes
3answers
149 views

Reverse a set of paragraphs

Is there a good way to reverse a set of paragraphs (navigable via cursor motion { and })? My practical use case is reversing the order of blocks of latex code (ie, reversing the order of jobs in a ...
1
vote
1answer
41 views

How do I move by paragraphs, but end up *in* the paragraph?

So I often use repeated invocations of gqip to re-wrap paragraphs of text or comments. Unfortunately, the quickest way I've memorized for moving between paragraphs, }, lands me between them: Qui⁁ut ...
2
votes
4answers
262 views

Delete from cursor position to end of text object

I often find myself in this situation: \foo{\bar abc \baz{def} more stuff} ↑ and I want to change anything from the cursor position to the correct enclosing brace. In simple cases, ct} ...
3
votes
1answer
137 views

:exe moves cursor to first line of buffer

function! DebugC() let l:debugStr = "printf(\"" . s:debugPrefixStr . s:debugCounter . "\");" if g:debugstringAlwaysIncludeHeader let l:incStr = "#include <stdio.h>; " ...
0
votes
1answer
35 views

Delete to next search result?

I often use dt, but that only deletes to a character. Is there something like dt that lets me type in a search instead of a single char? I would want to delete from my current cursor to that first ...
1
vote
1answer
51 views

Why doesn't “normal! lb” on last character of line move to beginning of word?

Let's say I have the text: foo bar baz With the cursor on z, I would expect :normal! lb to move the cursor to the first letter of baz. In actual fact the cursor does not move. However typing :...
1
vote
2answers
60 views

How do I prepend text preserving camelcase

A common process for me is to have a camelCased word that I wish to prepend to. I find the vanilla method a little too cumbersome as I will describe below. What I'm wondering is if there is a better ...
1
vote
3answers
92 views

A version of `w` which skips to the next underscore

I frequently work with code style which asks that many non-class symbols use snake_case -- Python, Ruby, and C especially. If I have a symbol like longfirstpart_longsecondpart, I'd like to be able to ...
2
votes
1answer
67 views

How to move to top/bottom of region delimited by consecutive blank lines

I have two commands for somewhat emulating the Emacs command narrow-to-defun. I have two commands that move to the top/bottom of the current paragraph nnoremap <silent> <leader>gt mp{...
2
votes
3answers
238 views

How to get around this common multiple-cursors use case?

I have a lot of difficulty doing things like the following in Vim: From 1 'apple' 2 'orange' 3 'pear' 4 $fruit1 = 5 $fruit2 = 6 $fruit3 = To 1 2 3 4 $fruit1 = 'apple'; 5 $fruit2 = 'orange'; 6 $...
4
votes
3answers
246 views

How to use 'w' to navigate in CamelCase words?

How would I use set iskeyword to be able to use w to count Capital letters as words? For example for the following sentence, ThisIsAShortSentence Pressing w will jump from T -> I -> A -> S -> S
3
votes
2answers
121 views

Highlight everything inside (, [, and { and expand outwards

Suppose I have a line of text of the form (123[456{789}abc]def) and the cursor is inside the curly braces. In sublime text, we can use ctrl-shift-m repeatedly to jump to highlighting 789, {789}, 456{...
1
vote
2answers
58 views

Replace a word in a stream of words separated with underscore

Does anyone know a quick shortcut I can use to replace a word in a series of words connected with underscores? Given: Create_in_one_of_these_words I want to make, where | is cursor: Create_in_|...
3
votes
0answers
64 views

how to delete a paragraph respecting the folds?

I have a file (filetype=javascript), this is how it looks without folds: and with folds: I can move with the { and } motions skipping the empty lines inside the folds (thanks to these question and ...
0
votes
1answer
63 views

Jump to specific character after cursor

What I want to do is jump to the first instance of character < X > after the cursor. I already know how to achieve this on the current line, but I was wondering if there was a way to apply this to ...
0
votes
1answer
362 views

how to remap backtick mark with single-quote mark globally [duplicate]

I want to swap ' with ` for all combinations of commands in normal mode. I have tried the following: nnoremap ' ` nnoremap ` ' It works for commands like '', ``, but failed for d'', y'', etc. ...
4
votes
1answer
50 views

How to search in visual mapping?

I am trying to create a text object for consecutive lower-case letters. Here is how I am setting up the inner text object: xnoremap in :<C-u>normal! ?[^a-z]?e+1<CR>v/[^a-z]/s-1<CR> ...
0
votes
1answer
44 views

How can you turn off text highlighting (hlsearch) with custom text objects?

I am implementing a custom text object in visual mode, but this text object uses regular expressions to find the beginning and ending of the selection. However, when I do this, other parts of the text ...
2
votes
0answers
134 views

Using text objects with IJKL navigation keys

Like many people, I prefer a triangular or inverse-T navigation key format like IJKL instead of HJKL for ergonomic reasons. There's a pretty simple way to set this up in vim that I've used for years: ...
2
votes
1answer
63 views

Prepare a range for an ex command without visual mode or line numbers

Background: I can pipe a paragraph through an external command using !ip and the cursor goes to the end of the following prompt: :.,.+5! If I want to use the built-in sort or center functions I ...
0
votes
2answers
70 views

Ammend 'w' behavior - ignore operators and brackets - '(', '[' '{', '*', '+', '='

As the title says. Is it possible? Steps to reproduce: Type in sample(text) and put the cursor on the first character then press w. Expected behavior: Cursor moves to beginning of next word - text ...
1
vote
1answer
36 views

How do I apply the Lowercase action to a line movement?

From the vim-as-language article: Vim’s "verbs" mostly fall into 2 main categories. Some of them act on a single character, and others act on a "motion" or "text object". And from the vim wiki for ...
1
vote
2answers
123 views

Prevent the cursor from moving to the top of the file

I started using Seeing is Believing and updated my vimrc: nmap <leader>s A # => <Esc>:%.!seeing_is_believing --timeout 12 --line-length 500 --number-of-captures 300 --alignment-...
5
votes
2answers
83 views

Linewise inner tag without the tag lines?

An example HTML, with the cursor where the brackets are: <foo> <bar> baz quux [] </bar> </foo> I would like to outdent the text inside <...
2
votes
3answers
638 views

Control - Arrow to Skip Over Text

I am new to Vim, however I am learning to love it. As a former/current Windows user, there is one shortcut that I depend on and would like to configure in Vim. On windows I can use ctrl-arrow left ...
0
votes
3answers
120 views

Add line at the end of text

I have 5000 text files in a folder with different names. I just need to add one more line to the end in all files. Example: HELLO HELLO HELLO HELLO I need make it HELLO HELLO HELLO HELLO abc ...
6
votes
5answers
454 views

truncate sentence: delete up to, but not including period

How can I set up a keybinding to delete up to the end of a sentence that ends with a period, but keep the period? The commands df., d), and D all truncate the sentence but don't keep the period. ...