Hot answers tagged

43 votes
Accepted

Multiple cursors at desired location

Using multiple cursor isn't a Vimmer thing As I said in the comments using multi cursors (even with a plugin) isn't really "following the Vim way", I totally understand that it is attractive for ...
  • 48.1k
25 votes
Accepted

How do I make Vim always display several lines after EOF?

You can use ctrlE to scroll down your file, when you are at the end of the file it will add "virtual" line so the last line of the file is not at the bottom of the windows. Additionally you can use ...
  • 48.1k
13 votes
Accepted

I can't switch to | cursor in insert mode

Neovim does not use vimrc it uses $XDG_CONFIG_PATH/nvim/init.vim. Yet, there is more to it. In Vim you should use \<esc> to represent the escape key. I can change the cursor on Arch Linux on ...
  • 1,636
13 votes
Accepted

Is there a prepend insert mode?

If you set :set revins you can insert backwards. See also :h ins-reverse: o Typing backwards ins-reverse ---------------- In lieu of using full-fledged ...
11 votes
Accepted

how can we put the cursor at mouse pointer

I assume you're using Vim in a terminal? The way the mouse works in a terminal is kinda weird: by default, it's the terminal that handles the mouse and Vim never sees anything. Because it's all text-...
10 votes
Accepted

Vim normal and insert mode cursor not changing in GNU screen

I think I figured it out, although I don't totally understand the fix. This appears to work for mintty, xterm, and rxvt: " Set up vertical vs block cursor for insert/normal mode if &term =~ "...
  • 451
10 votes
Accepted

No_cursor_blinking doesn't work

In gvim you use: set guicursor+=a:blinkon0 In vim run in the terminal you would change the terminal setting to disable the blinking.
  • 134
8 votes
Accepted

How can I get the character at the cursor position in a multibyte aware manner?

We discussed it less then 10 days ago on reddit. One solution is matchstr(getline('.'), '\%'.col('.').'c.') which doesn't mess with any register. I've put the resulting functions (we can ask for the ...
  • 16.6k
8 votes

How can you indent your current file without losing your cursor position?

You could define a custom command using :help winsaveview(): command! -range=% Equal let b:wv = winsaveview() | silent execute <line1> . ',' . <line2> . 'normal! ==' | call winrestview(b:...
  • 36k
8 votes
Accepted

CursorLine colors

The default syntax script for vim doesn't have lightyellow listed for vimHiCtermColor. You could patch it and submit your change to the vim_dev mailing list. Or, better, ask them if that is ...
  • 36k
8 votes

Multiple cursors at desired location

More Vim ways. First task: \section[foobar baz]{foobar baz} Workflow: \section[]{} hh ifoobar baz<Esc> $. Second task: variable1 = 2 my_variable2 = 12 var3 = 14 Command: 3:norm ...
  • 36k
8 votes

Change cursor shape in different terminals

As of November 2017, all the terminals you are using support the same DECSCUSR escape sequences for changing the cursor shape1. So you don't need to test for the different terminals. As such, the ...
  • 30.1k
8 votes
Accepted

getpos(".") in visual mode equals getpos("v")

The problem you're having here is that by the time show_position() is running you're already out of visual mode, since the : switched to command-line mode before that function gets called. If you ...
  • 27.3k
6 votes

Multiple cursors at desired location

Your given use-cases to me sound like to want to know the . key command (repeat last Editing command) Go to first place, press i, insert your text, <ESC> move to location 2, press . (Dot) ==> ...
6 votes
Accepted

Move cursor to new line character

If you simply want the cursor to be able to go one past the end of the line for the purpose of starting visual mode, you want the setting set virtualedit=onemore (see :help 've). However, this does ...
  • 13.5k
6 votes
Accepted

Reclaim cursor shape in operator pending mode of neovim while using vim-surround

If vim-surround were implemented as 's' and 'S' (pseudo-)text-objects instead of operators ds, dS, cs, cS etc, this wouldn't be an issue. I don't know if there's some technical reason for this design ...
  • 13.5k
6 votes

Regex pattern matching cursor-position

You can use the atom /\&. This is like forcing two different regular atoms to match at the same position. Now it becomes a bit complicated, since the cursor position can be anywhere inside the &...
6 votes

changing cursor to block in insert mode on Neovim

enter this command in vim to use block cursor in insert mode: :set guicursor=i:block
5 votes

How can you indent your current file without losing your cursor position?

Expanding on Karl Yngve Lervåg's answer: maHmbgg=G`bzt`a Explanation: ma - Set mark 'a' H - Jump to the top of the window mb - Set mark 'b' gg=G - Indent from the first line to the last `b ...
  • 6,570
5 votes

How to scroll without forcing the cursor on screen (by letting the cursor off screen)?

I am used from other editors to use the cursor as a visual bookmark, so that after scrolling by letting the cursor off screen I can come back to its place later. If you're just scrolling through the ...
5 votes

How do I make Vim always display several lines after EOF?

In your config you can add zz to j and k. It has the major side effect of centering your cursor. I don't mind and much prefer it to craning my neck. I tried scrolloff and CTRL-E is just uncomfortable ...
  • 51
5 votes

How to disable moving the cursor with the mouse

From Vim Tips Wiki: When you are using another application and select go back to Vim by clicking inside Vim's text area, it not only switches application focus to Vim, but it also moves the ...
5 votes

gvim Linux - GUI scroll without cursor shift

Vim doesn't remember where you've been in a file unless you made a change there (see :help changelist) or jumped there (see help jumplist). Also, Vim's cursor is always somewhere in a window, that is, ...
  • 6,144
5 votes
Accepted

creating a ":KeepCursor" command

Can it be written? Yup. command! -nargs=* -complete=command KeepCursor \ let [s:view, s:win] = [winsaveview(), win_getid()] | \ try | \ execute <q-args> | \ finally | ...
5 votes
Accepted

Neovim does not restore terminal cursor on exit

You can and add this to your init.vim: augroup RestoreCursorShapeOnExit autocmd! autocmd VimLeave * set guicursor=a:hor20 augroup END See :h guicursor for details. The reason it isn't done ...
  • 1,960
5 votes

How to change vim cursor shape in text console?

Found a related discussion. cnorm on my machine is \E[?25h\E[?0c The tail \E[?0c will always reset cursor shape. I thought I can use t_SI and t_EI if I remove it from cnorm (it's termcap code is ...
  • 6,038
5 votes
Accepted

How do I change vim cursor color

You can only change GUI vim cursor color in vim: augroup tune_colors | au! au ColorScheme * hi Cursor guibg=red guifg=white augroup END If you use terminal vim, change cursor colors in terminal ...
  • 12k
5 votes
Accepted

How to move cursor to previous line automatically?

The option is called :h 'whichwrap' (or ww for short). For example, set ww+=<,>,[,] However, "right arrow" only goes onto the next line if you don't have set virtualedit=all (that you ...
  • 19.2k
4 votes

How to restore cursor position after search and replace in autocmd

You could achieve '' on an autocmd using the following: :call setpos('.', getpos("''")) Check :help function-list for built-in functionality on VimL. Edit okay, how to combine it with search and ...
  • 6,520
4 votes
Accepted

cursor behavior when exiting <insert> mode

Thanks to the comment by @muru I was able to figure this out. I turns out in my .vimrc I had this line to remap jk to <esc> inoremap jk <esc> but there was a space inserted at the end ...
  • 219

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