Navigation
Related:
Themes:
VIM = Vi IMproved
by Frans Moolenaar et al.
~/.vimrc
set clipboard=unnamed
set nu
" SPLITTING
set splitbelow
set splitright
"split navigations
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" ENCODING
set encoding utf-8
" TABBING
au BufNewFile,BufRead *.py
\ set tabstop=4
\ set softtabstop=4
\ set shiftwidth=4
\ set textwidth=79
\ set expandtab
\ set autoindent
\ set fileformat=unix
au BufNewFile,BufRead *.js, *.html, *.css
\ set tabstop=2
\ set softtabstop=2
\ set shiftwidth=2
" COLORING (vary with darkness)
"highlight Comment ctermfg=LightCyan
Mapping in vimrc
vnoremap <C-n> :norm
nnoremap <F7> :tabn
nnoremap <F8> :tabp
nnoremap <C-t> :tabe
nnoremap <C-Tab> :tabn
nnoremap <C-S-Tab> :tabp
From a Nice Stackoverflow discussion showing multiple ways to Rome.
1. visually select the text rows (using V as usual)
2. :norm i#
This inserts "#" at the start of each line. Note that when you type : the range will be filled in, so it will really look like :'<,'>norm i#
1. visually select the text as before (or type gv to re-select the previous selection)
2. :norm x
This deletes the first character of each line. If I had used a 2-char comment such as // then I'd simply do :norm xx
to delete both chars.
If the comments are indented as in the OP's question, then you can anchor your deletion like this:
:norm ^x
which means "go to the first non-space character, then delete one character".
Note: Since norm
is literally just executing regular vim commands, you're not limited just to comments, you could do some complex editing to each line. If you need the escape character as part of your command sequence, type ctrl-v then hit the escape key.
Note 2: You could of course also add a mapping if you find yourself using norm a lot. Eg putting the following line in ~/.vimrc lets you type ctrl-n
instead of :norm
after making your visual selection
vnoremap <C-n> :norm
Note 3: Bare-bones vim sometimes doesn't have the norm command compiled into it, so be sure to use the beefed up version, ie typically /usr/bin/vim, not /bin/vi
(Thanks to @Manbroski and @rakslice for improvements incorporated into this answer)
:tabe <filename>
To switch:
:tabn
:tabp
Map keys, e.g. F7
/F8
to :tabn/:tabp
Indent: >>
Deindent: <<
in Python, this is four spaces. Perfect!
TODO: try out ctrl+p
VIM and Python - a Match Made in Heaven (from RealPython)
https://www.youtube.com/watch?v=PlXP2Zze380
https://github.com/VundleVim/Vundle.vim/wiki/Vundle-for-Windows
https://github.com/amix/vimrc
Add to ~/.vimrc:
highlight Comment ctermfg=LightCyan
Note: only useful in dark mode.