Do you easily get distracted when you are writing with social media, your cellphone, etc.? This is a list of free apps to help you stay focused on your writing. You may also want to read our article How to enter the flow state.
Create a file: vim file_name. Vim has different modes of operation. The main modes are:
Vim provides a built-in tutor to teach you the basics, just type: vimtutor. Vim has an extensive help system: :help, :help subject.
To quit the editor without saving, type :q!. To save your changes (write your changes to the file), type :w. Finally, to save and quit, :wq.
To start editing the file content like you would do with any other text editor, switch into insert mode by pressing the i key and type in any text before the cursor or pressing the a key and type in right after the cursor.
To move in the text in normal mode you can use the arrows keys or H (left), J (down), K (up), and L (right). You can type x to delete a simple character, dd an entire line, d$ from current position to the end of the line, u to undo the last change or press CTRL-r to redo changes. You may want to copy from the clipboard: Ctrl + Shift + V.
Copy/Paste: Press v to enter visual mode and move your left and right arrow keys to select and deselect some text, then press y to copy or yank the text (d: cut in Visual Mode) in Visual Mode to the clipboard. Finally, hit p to paste it (or put it) somewhere else.
Vim
Useful commands: :set number it shows line numbers in the editor; !python mySourceFile.py (run it). Copy and Paste: yw (yank or copy a word) + p (put/paste), yy (yank or copy an entire line) + p(put/paste) or y$ (yank/copy to the end of the current line) + p. Forward Search /text, Backward search: ?text, n moves to the next match.
Neovim is an hyperextensible Vim-based text editor. vim-plug is a minimalist Vim plugin manager.
# Install vim-plug in Linux, Neovim
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
# Install vim-plug in Windows, Neovim, PowerShell
iwr -useb https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |`
ni "$(@($env:XDG_DATA_HOME, $env:LOCALAPPDATA)[$null -eq $env:XDG_DATA_HOME])/nvim-data/site/autoload/plug.vim" -Force
set encoding=utf-8 " Sets how vim shall represent characters internally. Utf-8 is necessary for most flavors of Unicode.
syntax enable " Enables syntax highlighting.
set noswapfile " Disables swap files.
set scrolloff=7 " There are always at least 7 lines visible above and below the cursor.
" Allow backspacing work like in most other programs
set backspace=indent,eol,start
set tabstop=4 " The width of a tabstop, a Tab in the file counts for 4 spaces.
set softtabstop=4
set shiftwidth=4
set expandtab " The tab key will insert spaces instead of tab characters.
set autoindent " Automatically indent lines
set fileformat=unix
set ruler " Show the line and column number of the cursor position.
set mouse=a " Enable your mouse
let mapleader = ';' " Set leader key
set number " Print the line number in front of each line.
set clipboard=unnamedplus " Copy paste between vim and everything else
set spelllang=en,es,cjk " Spell languages
" To use vim-plug, we add a vim-plug section. It specifies a directory for plugins and list the plugins with Plug commands.
call plug#begin('~/.vim/plugged')
Plug 'morhetz/gruvbox' " (*1) Adding gruvbox, a bright theme with pastel retro groove colors.
gruvbox is a bright theme with pastel ‘retro groove’ colors and light/dark mode switching in the way of solarized. First, you need to add Plug ‘morhetz/gruvbox’ (*1) to your .vimrc and run :PlugInstall. Second, we use it: set background=dark, colorscheme gruvbox (*2)
Plug 'jiangmiao/auto-pairs' " Insert or delete brackets, parens, quotes in pair.
Plug 'preservim/nerdtree' " The NERDTree is a file system explorer for the Vim editor.
Plug 'tpope/vim-commentary' " A plugin that allows for easy commenting of code. Use gcc to comment out a line.
Plug 'norcalli/nvim-colorizer.lua' " A high-performance color highlighter for Neovim which has no external dependencies!
Plug 'vim-airline/vim-airline' "Setting up a status bar for vim that's light as air
Plug 'vim-airline/vim-airline-themes' "This is the official theme repository for vim-airline.
Plug 'plasticboy/vim-markdown'
" Initialize plugin system
call plug#end()
set background=dark " Set up the dark mode. (*2)
colorscheme gruvbox " Set up the grubbox theme. (*2)
let g:airline_theme='gruvbox' "Set up the status bar's theme.
if (has("termguicolors"))
set termguicolors
endif
lua require 'colorizer'.setup() " One line setup for the nvim-colorizer's plugin.
" NERDTree Ctrl+T toogle NERDTree view.
nnoremap <C-t> :NERDTreeToggle<CR>
" F11 Toggle spell. To correct the error, you can press Ctrl, X, followed by s
nnoremap <silent> <F11> :set spell!<cr>
inoremap <silent> <F11> <C-O>:set spell!<cr>
You can visit Open Vim to learn and practice Vim with an interactive tutorial.