Hot answers tagged

26 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 ...
statox's user avatar
  • 49.6k
14 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 ...
Christian Brabandt's user avatar
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 ...
grochmal's user avatar
  • 1,656
11 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 =~ "...
ZeroG's user avatar
  • 471
11 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.
tluafed's user avatar
  • 144
11 votes
Accepted

How to navigate long lines like separate lines?

You can use the gj and gk commands to move the cursor to the character in the next or previous display lines, even when lines wrap. See :help gj and :help gk for details. If you would like to ...
Maxim Kim's user avatar
  • 13.1k
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-...
Martin Tournoij's user avatar
9 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 ...
romainl's user avatar
  • 40k
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 ...
Rich's user avatar
  • 31.7k
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 ...
romainl's user avatar
  • 40k
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 ...
Luc Hermitte's user avatar
  • 17.3k
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:...
romainl's user avatar
  • 40k
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 ...
filbranden's user avatar
  • 28.6k
8 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
network_dios's user avatar
6 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 ...
mitlenatch's user avatar
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 ...
Mass's user avatar
  • 14k
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 ...
Mass's user avatar
  • 14k
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 &...
Christian Brabandt's user avatar
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 ...
Tommy A's user avatar
  • 6,750
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 ...
Alexander Batischev's user avatar
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 ...
hello's user avatar
  • 51
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, ...
garyjohn's user avatar
  • 6,299
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 | ...
Peter Rincker's user avatar
5 votes
Accepted

Yank then Paste without moving cursor

You can define your special version of "put" like this: command! -bar -bang -range -register Put call append(<line2> - <bang>0, getreg(<q-reg>, 1, 1)) Now 13Pu works without any ...
Matt's user avatar
  • 20.6k
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 ...
Tae's user avatar
  • 2,105
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 ...
dedowsdi's user avatar
  • 6,238
5 votes
Accepted

How can I make zz not center cursor when approaching end of file?

If you're willing to bring a function into the mix I whipped this up... func! ModifiedZZ() " modify to your liking let l:max_pad_lines = 10 norm! zz let l:to_scr_end = winheight(...
B Layer's user avatar
  • 19.7k
5 votes
Accepted

How come the Vim cursor leaves one character at the end of the line?

Why does it do this? Cursor is on a character that has actual place in a buffer. After the last character there is no actual place to put cursor on. Unless you use virtual place. And is there a way ...
Maxim Kim's user avatar
  • 13.1k
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 ...
Maxim Kim's user avatar
  • 13.1k
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 ...
Matt's user avatar
  • 20.6k

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