diff --git a/blogContent/posts/open-source/media/vim/commandCompletion.png b/blogContent/posts/open-source/media/vim/commandCompletion.png new file mode 100644 index 0000000..95312f3 Binary files /dev/null and b/blogContent/posts/open-source/media/vim/commandCompletion.png differ diff --git a/blogContent/posts/open-source/the-essential-vim-configuration.md b/blogContent/posts/open-source/the-essential-vim-configuration.md new file mode 100644 index 0000000..f2d401c --- /dev/null +++ b/blogContent/posts/open-source/the-essential-vim-configuration.md @@ -0,0 +1,188 @@ +# Vim Configuration + +Stock Vim is pretty boring. +The good news is that Vim has a very comprehensive configuration file which +allows you to tweak it to your heart's content. +To make changes to Vim you simply modify the ~/.vimrc file in your home +directory. +By adding simple commands this file you can easily change the way your +text editor looks. +Neat. + +I attempted to create the smallest Vim configuration file which makes +Vim usable enough for me to use as my daily text editor. +I believe that it is important for everyone to know what their +Vim configuration does. +This knowledge will help ensure that you are only adding the things +you want and that you can later customize it for your workflow. +Although it may be tempting to download somebody else's massive Vim +configuration, I argue that this can lead to problems down the road. + +I want to mention that I don't use Vim as my primary +IDE; I only use Vim as a text editor. +I tend to use JetBrains tools on larger projects since they have amazing +auto complete functionality, build tools, and comprehensive error detection. +There are great Vim configurations out there on the internet; however, most +tend to be a bit overkill for what most people want to do. + +Alright, lets dive into my vim configuration! + + +# Spell Check + +```vim +autocmd BufRead,BufNewFile *.md setlocal spell spelllang=en_us +autocmd BufRead,BufNewFile *.txt setlocal spell spelllang=en_us +``` + +Since I am often an atrocious speller, having basic spell check abilities in +Vim is a lifesaver. +It does not make sense to have spell check enabled for most files since it +would light up most programming files like a Christmas tree. +I have my Vim configuration set to automatically enable spell check for markdown files +and basic text files. +If you need spell check in other files, you can enter the command +":set spell" to enable spell check for that file. +To see the spelling recommendations, type "z=" when you are over a +highlighted word. + + +# Appearance + +Adding colors to Vim is fun. +The "syntax enable" command tells vim to highlight keywords in programming +files and other structured files. + +```vim +syntax enable +``` + +I would encourage everyone to look at the different color schemes available for +Vim. +I threw the color scheme command in a try-catch block to ensure that it does not crash +Vim if you don't have the color scheme installed. +By default the desert color scheme is installed; however, that is not always the +case for [community created](http://vimcolors.com/) Vim color schemes. + +```vim +try + colorscheme desert +catch +endtry + +set background=dark +``` + +# Indentation and Tabs + +Having your indentation settings squared away will save you a ton of time +if you are doing any programming in Vim. + +```vim +"copy indentation from current line when making a new line +set autoindent +" Smart indentation when programming: indent after { +set smartindent + +set tabstop=4 " number of spaces per tab +set expandtab " convert tabs to spaces +set shiftwidth=4 " set a tab press equal to 4 spaces +``` + +# Useful UI Tweaks + +These are three UI tweaks that I find really useful to have, some people may +have different opinions on these. +Seeing line numbers is useful since programming errors typically just +tells you what line your program went up in flames. +The cursor line is useful since it allows you to easily to find your place +in the file -- this may be a bit too much for some people. + +I like to keep every line under 80 characters long for technical files, +having a visual queue for this is helpful. +Some people prefer to just use the auto word wrap and keep their lines as long +as they like. +I like to keep to the 80 character limit and explicitly choose where +I cut each line. +Some of my university classes mandate the 80 character limit and take +points off if you don't follow it. + +```vim +" Set Line Numbers to show " +set number + +" Highlights the entire current line with a underscor " +set cursorline + +" Displays a red bar at 80 characters " +set colorcolumn=80 +``` + + +# Searching and Auto Complete + +This these configurations make searching in Vim less painful. + +```vim +" search as characters are entered " +set incsearch +" highlight matched characters " +set hlsearch + +" Ignore case when searching " +set ignorecase +``` + +These configurations will make command completion easier by +showing an auto-complete menu when you press tab. + +```vim +" Shows a auto complete menu when you are typing a command " +set wildmenu +set wildignorecase " ignore case for auto complete +``` + +![Vim auto complete](media/vim/commandCompletion.png) + + +# Useful Things to Have + +There is nothing too earth shattering in this section, just things that +might save you some time. +Enabling mouse support is a really interesting configuration. +When enabled, this allows you to select text and jump between different +locations with your mouse. + +```vim +" Enables mouse support " +set mouse=a + +"Disable ding sound on error, flashes cursor instead " +set visualbell + +" Display ruler on bottom right -- should be there by default " +set ruler + +" Auto updates file if an external source edits the file " +set autoread + +" Improves performance by only redrawing screen when needed " +set lazyredraw +``` + +Setting your file format is always a good idea for compatibility. + +```vim +" Set utf8 as standard encoding and en_US as the standard language " +set encoding=utf8 + +" Use Unix as the standard file type " +set ffs=unix,dos,mac +``` + +# Wrapping it up + +I hope that this quick blog post inspired you to maintain your own Vim +configuration file. +You can find my current configuration files in my +[random scripts repository](https://github.com/jrtechs/RandomScripts/tree/master/config). diff --git a/blogContent/posts/other/the-essential-vim-configuration.md b/blogContent/posts/other/the-essential-vim-configuration.md deleted file mode 100644 index ee7897f..0000000 --- a/blogContent/posts/other/the-essential-vim-configuration.md +++ /dev/null @@ -1,146 +0,0 @@ -# Vim Configuration - -Stock vim is pretty boring. -The good news is that vim has a very comprehensive configuration file which -allows you to tweak it to your liking. -To make changes to vim you simply modify the ~/.vimrc file in your home -directory. -By adding simple commands this file you can easily change the way your text editor looks. - -When most people get started with vim configurations, they will simply heave -a few massive vim configurations into their vimrc file. -In addition to basic vim configurations, there are also hundreds of plugins -which you can install. -The problem with shoveling a ton of stuff in your vim configuration and installing a ton -of plugins is that it becomes a pain maintain. -Making simple changes is more difficult when you have to wade through a sea of gobble -gook configurations that you did not write. -Also, if you have a ton of vim plugins it is difficult to transfer them to a new system -since you have to look up how to install all the dependencies. - -When designing my vim configuration I decided to use the minimum amount -configurations as possible to make vim the most usable for me. -I feel that it is important for everyone to know exactly what every line of their -vim configuration does. -This will ensure that you are only adding the things that you want and you can -customize it for your workflow. - -As a small disclaimer, I want to mention that I don't use vim as my primary -IDE. -When working on any large project I tend to use a JetBrains product or VSCode -because of the auto complete functionality and code generation. -There are great vim configurations out there on the internet; however, most -tend to be a bit overkill for what most people want to do. - - -# Spell Check - -```vim -autocmd BufRead,BufNewFile *.md setlocal spell spelllang=en_us -autocmd BufRead,BufNewFile *.txt setlocal spell spelllang=en_us -``` - - -# Appearance - -```vim -syntax enable -``` - - -```vim -" Enable 256 colors palette in Gnome Terminal -if $COLORTERM == 'gnome-terminal' - set t_Co=256 -endif - -try - colorscheme desert -catch -endtry - -set background=dark - -" Set extra options when running in GUI mode -if has("gui_running") - set guioptions-=T - set guioptions-=e - set t_Co=256 - set guitablabel=%M\ %t -endif -``` - -# Indentation and Tabs - -```vim -" search as characters are entered -set incsearch -" highlight matched characters -set hlsearch - -" Ignore case when searching -set ignorecase -``` - - -# Useful UI Tweaks - -```vim -" Set Line Numbers to show -set number - -" Highlights the current line with a underscore -set cursorline - -" Displays a red bar at 80 characters -set colorcolumn=80 -``` - - -# Searching and Auto Complete - -```vim -" Shows a auto complete tab when you are typing a command -" like :sp -set wildmenu -set wildignorecase - -" Searching when in command mode type /words to find -" search as characters are entered -set incsearch -" highlight matched characters -set hlsearch - -" Ignore case when searching -set ignorecase -``` - -# Useful Things to Have - - -```vim -"Disable ding sound on error, flashes cursor instead -set visualbell - -" Display ruler on bottom right -- should be there by default -set ruler - -" Enables mouse support -set mouse=a - -" Auto updates file if an external source edits the file -set autoread - -" Improves performance by only redrawing screen when needed -set lazyredraw -``` - - -```vim -" Set utf8 as standard encoding and en_US as the standard language -set encoding=utf8 - -" Use Unix as the standard file type -set ffs=unix,dos,mac -``` - diff --git a/run b/run index bf2733a..ecd6bd8 100755 --- a/run +++ b/run @@ -1,9 +1,10 @@ #!/bin/bash -# run - this script enters a infinite loop to ensure that the website does not go down if it -# hits any unexpected error that crashes Nodejs +# This script runs the server in an infinite loop to ensure +# that the website does not go down if it hits any +# unexpected error that crashes Nodejs # # 2/13/18 Jeffery Russell while true do node server.js -done \ No newline at end of file +done