Nishkarsh_Arora's blog

By Nishkarsh_Arora, history, 4 years ago, In English

Hello, Codeforces!! Many people ask for the best text editor for the programming contest. So, according to me vim is a great tool for competitive programming. It is not very comfortable to use it at first but after some time you will feel it is the best text editor ever made. So, I am going to help setup VIM(for windows) and make is ready to use for competitive programming.

WHY VIM??

I suggest, just try vim and you will get to know. But, if you are curious you can refer: https://medium.com/@fay_jai/what-is-vim-and-why-use-vim-54c67ce3c18e

You can download vim from https://www.vim.org/download.php, just download the Self-installing executable file, install it by keeping all the settings default.

Now, just launch Gvim from the start menu and you will enter a page where you would not be able to understand much but don't worry I am here to help you.

At the start, you will be in normal mode, just type :e ~\desktop\main.cpp, this will create a new file on your desktop(or if it already exists it will open it). To edit the document you have enter into insert mode(by pressing "i" key on your keyboard).

Initially, you will see a very ugly text.

But it can be improved an will look like this

For this, you have to make a _vimrc file in your home directory.

This is my _vimrc file, you can copy mine or can make your own...

syntax on
set noerrorbells
set tabstop=4 softtabstop=4
set smartindent
set smarttab
set autoindent
set cindent
set shiftwidth=4
set expandtab
set nu
set relativenumber
set ruler
set guifont=*
set backspace=indent,eol,start
set clipboard=unnamed
nnoremap <C-Right> :tabnext<CR>
nnoremap <C-Left> :tabprevious<CR>
autocmd filetype cpp nnoremap <F5> :w <bar> !g++ -std=c++17 -O2 -Wall % -o %:r && %:r.exe <CR>
set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}
Plugin 'ycm-core/YouCompleteMe'
Plugin 'gruvbox-community/gruvbox'
Plugin 'vim-utils/vim-man'
Plugin 'sainnhe/gruvbox-material'
Plugin 'phanviet/vim-monokai-pro'
Plugin 'vim-airline/vim-airline'
Plugin 'flazz/vim-colorschemes'
Plugin 'ajh17/VimCompletesMe'
" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList       - lists configured plugins
" :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
let g:gruvbox_contrast_dark = 'hard'
if exists('+termguicolors')
    let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
    let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
endif
let g:gruvbox_invert_selection='0'

" --- The Greatest plugin of all time.  I am not bias
" let g:vim_be_good_floating = 0

" --- vim go (polyglot) settings.
let g:go_highlight_build_constraints = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_operators = 1
let g:go_highlight_structs = 1
let g:go_highlight_types = 1
let g:go_highlight_function_parameters = 1
let g:go_highlight_function_calls = 1
let g:go_highlight_generate_tags = 1
let g:go_highlight_format_strings = 1
let g:go_highlight_variable_declarations = 1
let g:go_auto_sameids = 1

colorscheme gruvbox
set background=dark

Save this file by going into normal mode and typing :w, then type :source % and select your desired font.

You should also have git installed, to install plugins.

Now, you are almost done just follow some simple steps from this link(to install some useful plugins for visuals) https://github.com/VundleVim/Vundle.vim

Again type :source %, and you have the best setup for programming. Also, you can compile and run your file by just pressing F5.

You can also comment if you have any doubts. THANKS!!!

Full text and comments »

  • Vote: I like it
  • -16
  • Vote: I do not like it

By Nishkarsh_Arora, history, 4 years ago, In English

I spent a lot of time debugging my code, but found nothing, can you guys help me with this problem: https://mirror.codeforces.com/contest/1363/problem/E

My code: https://mirror.codeforces.com/contest/1363/submission/85540470

THANKS IN ADVANCED!!!

Full text and comments »

  • Vote: I like it
  • -20
  • Vote: I do not like it