Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code Vim: How do you highlight current line?

How do you highlight the current line using Vim VS Code?

This functionality would be awesome. Anyone know if this configuration is possible in Vim VS Code? http://vim.wikia.com/wiki/Highlight_current_line

Especially Highlighting that stays after cursor moves:

:nnoremap <silent> <Leader>l ml:execute 'match Search /\%'.line('.').'l/'<CR>
like image 673
Matt_James Avatar asked Dec 22 '17 08:12

Matt_James


2 Answers

Try this in your settings.json:

"workbench.colorCustomizations": {

  "editor.lineHighlightBackground": "#ff0000"
}

This assumes that you have

  "editor.renderLineHighlight": "line",

(that is the default) set to "line" or ""all".

[EDIT after your comment about selecting]

I am not exactly sure what you are looking to do but Ctrl-C selects the current line and Ctrl-I highlights the entire line but doesn't select it. In neither case does the highlighting stay on a previous line after you move the cursor.

like image 75
Mark Avatar answered Oct 18 '22 10:10

Mark


Shiftv toggles visual line, not sure if you've discovered that yet or not.

It's worth pointing out that in Vim, you don't need to highlight to act on or manipulate the current line (as I see you're trying to do in your comment to another answer). In fact, it's often better/faster not to. For example:

  • dd: delete linewise
  • Shiftd: delete from cursor to end of line
  • yy: yank linewise
  • Shifty: yank from cursor to end of line
  • cc: change linewise
  • Shiftc: change from cursor to end of line
  • >>: indent line
  • <<: unindent line

If you find yourself in visual mode a lot, that can be a sign that you haven't yet become comfortable with text object motions and text object selection.

like image 21
Rich Churcher Avatar answered Oct 18 '22 10:10

Rich Churcher