Tuesday, 2 October 2018

Vim editor tips

Split into 2 screen:

  

  • split your screen in multiple files horizontal: :sp <filepath>\

  • switch between splitscreens with Ctrl+W

  •  :vsp or :vp is for vertical split. Then use Ctrl+W <ARROW_KEYS> to move in panes.

:n -> Move to next file
:N -> Move to previous file

Vimdiff colorscheme:


List all the installed color schemes in VIM:

Type
:colorscheme then Space followed by TAB.
or as Peter said,
:colorscheme then Space followed by CTRLd
or path: /usr/share/vim/vim74/colors/b

Load different colorscheme when using vimdiff


if &diff
    colorscheme some_other_scheme
endif

Hence the .vimrc file content:


" Set colorscheme only to Vimdiff if use from command line " Check the colorschme for vimdiff and collected below "      pablo -> good, slate -> ok, blue -> Very dark
if &diff     colorscheme pablo endif

Complete .vimrc file content:



"Indents braces set cindent
"Indents by 4 spaces set shiftwidth=4
"Prevents spaces from being converted to tabs "set expandtab
"To hightligth the search word" set hlsearch
" Red line verital mark "set cc=80
" Once it reace 79 it will automatically come to next line "set tw=79
" always add a space after comma " Enable it only if you keep on forgetting space after comma " inoremap , ,<space>
" strcpy, strncpy, strcat, strncat, sprintf, strtok, memcpy are banned APIs. " Highlight them as Error, to prevent accidental usage. match Error /\<strcpy\>\|\<strncpy\>\|\<strcat\>\|\<strncat\>\|\<sprintf\>\|\<strtok\>\|\<memcpy\>/
fun! VerifySyntaxError()         highlight default link LinuxError ErrorMsg
        syn match LinuxError / \+\ze\t/     " spaces before tab         syn match LinuxError /\%>80v[^()\{\}\[\]<>]\+/ " virtual column 81 and more
        " Highlight trailing whitespace, unless we're in insert mode and the         " cursor's placed right after the whitespace. This prevents us from having         " to put up with whitespace being highlighted in the middle of typing         " something         autocmd InsertEnter * match LinuxError /\s\+\%#\@<!$/         autocmd InsertLeave * match LinuxError /\s\+$/ endfunction
map <F5> :call VerifySyntaxError()<CR>
" Vel Adding list : " For ctags, to use ctrl + ] option set cscopetag
" Set colorscheme only to Vimdiff if use from command line " Check the colorschme for vimdiff and collected below "      pablo -> good, slate -> ok, blue -> Very dark
if &diff     colorscheme pablo endif



No comments:

Post a Comment