From ce612acd3758edf025e63a20bd66827a52e69eee Mon Sep 17 00:00:00 2001 From: mohammadkhan Date: Sat, 16 Dec 2023 23:41:06 +0530 Subject: [PATCH 1/3] docs: Add documentation for vim mode --- .gitignore | 1 + content/docs/preferences/code-edit/_index.md | 153 +++++++++++++++++++ content/docs/tips/_index.md | 6 + 3 files changed, 160 insertions(+) diff --git a/.gitignore b/.gitignore index 07b3a1535..d46d2e636 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ tech-doc-hugo dist/ tmp/ *.lock +.DS_Store diff --git a/content/docs/preferences/code-edit/_index.md b/content/docs/preferences/code-edit/_index.md index 1414c0f3a..8b8834517 100644 --- a/content/docs/preferences/code-edit/_index.md +++ b/content/docs/preferences/code-edit/_index.md @@ -45,3 +45,156 @@ You can choose the parentheses to jump out by Tab in the [Parentheses](../langua When you insert an indent, insert spaces instead of a tab character. The number of spaces is equal to the [Tab Width](#tab-width). Note that this won't replace the existing tab characters. In [Auto Indent](#auto-indent), the tab characters in the old line will remain in the new line (however, the new indent inserted after `{` will be spaces). + +### Enable Vim emulation + +If enabled, code editor will emulate vim behaviour. In vim emulation, Control Key such as Ctrl+N will not be intercepted by CP Editor but by Code Editor. We provide some custom commands that can perform various tasks like opening new tab, running testcases etc. [Here](#custom-vim-commands) is a list of all supported custom vim commands. + +### Vim configuration + +The configuration to use in vim mode. The list of all supported vim commands are listed [here](../general/\_index.md#vim-commands) + +### Vim Commands + +#### Supported Features + +Most of supported commands can be followed by motion command or executed in visual mode, work with registers or can be prefixed with number of repetitions. + +Here is list of emulated commands with description where it can diverge from Vim in functionality. + +#### Modes + +- normal +- insert and replace +- visual +- command line (`:`) + +#### Normal and Visual Modes + +- basic movement -- `h`/`j`/`k`/`l`, ``, ``, ``, ``, `gg`, `G`, `0`, `^`, `$` etc. +- word movement -- `w`, `e`, `b` etc. +- "inner/a" movement -- `ciw`, `3daw`, `ya{` etc. +- `f`, `t` movement +- `[`, `]` movement +- `{`, `}` -- paragraph movement +- delete/change/yank/paste with register +- undo/redo +- ``, `` -- increase or decrease number in decimal/octal/hexadecimal format (e.g. `128` on or before "0x0ff" changes it to "0x17f") +- `.` -- repeat last change +- `/search`, `?search`, `*`, `#`, `n`, `N` -- most of regular expression syntax used in Vim except `\<` and `\>` just is the same as `\b` in QRegExp +- `@`, `q` (macro recording, execution) -- special keys are saved as `` +- marks +- `gv` -- last visual selection; can differ if text is edited around it +- indentation -- `=`, `<<`, `>>` etc. with movement, count and in visual mode +- "to upper/lower" -- `~`, `gU`, `gu` etc. +- `i`, `a`, `o`, `I`, `A`, `O` -- enter insert mode +- scroll window -- `zt`, `zb`, `zz` etc. +- wrap line movement -- `gj`, `gk`, `g0`, `g^`, `g$` + +#### Command Line Mode + +- `:map`, `:unmap`, `:inoremap` etc. +- `:source` -- very basic line-by-line sourcing of vimrc files +- `:substitute` -- substitute expression in range +- `:'<,'>!cmd` -- filter through an external command (e.g. sort lines in file with `:%!sort`) +- `:.!cmd` -- insert standard output of an external command +- `:read` +- `:yank`, `:delete`, `:change` +- `:move`, `:join` +- `:20` -- go to address +- `:history` +- `:registers`, `:display` +- `:nohlsearch` +- `:undo`, `:redo` +- `:normal` +- `:<`, `:>` + +#### Insert Mode + +- `` -- execute single command and return to insert mode +- `` -- insert raw character +- `` -- toggle replace mode + +#### Options (:set ...) + +- `autoindent` +- `clipboard` +- `backspace` +- `expandtab` +- `hlsearch` +- `ignorecase` +- `incsearch` +- `indent` +- `iskeyword` +- `scrolloff` +- `shiftwidth` +- `showcmd` +- `smartcase` +- `smartindent` +- `smarttab` +- `startofline` +- `tabstop` +- `tildeop` +- `wrapscan` + +#### Example Vimrc + +```vimrc +" highlight matched +set hlsearch +" case insensitive search +set ignorecase +set smartcase +" search while typing +set incsearch +" wrap-around when searching +set wrapscan +" show pressed keys in lower right corner +set showcmd +" tab -> spaces +set expandtab +set tabstop=4 +set shiftwidth=4 +" keep a 5 line buffer for the cursor from top/bottom of window +set scrolloff=5 +" X11 clipboard +set clipboard=unnamed +" use ~ with movement +set tildeop +" mappings +nnoremap ; : +inoremap jj +" clear highlighted search term on space +noremap :nohls +" reselect visual block after indent +vnoremap < >gv +" MOVE LINE/BLOCK +nnoremap :m+== +nnoremap :m-2== +inoremap :m+==gi +inoremap :m-2==gi +vnoremap :m'>+gv=gv +vnoremap :m-2gv=gv +``` + +### Custom Vim commands + +In this section we present a list of all custom vim commands that are supported to perform different operation in CP Editor. + +| Command | Shorthand | Description | Usage | +| :----------: | :-------: | :-----------------------------------------------------------------------------------------------------------------------: | :-------------------------: | +| `new` | `new` | Opens a new tab, if no langauge is specified, a tab in default editor langauge will open | `new cpp` or `new` | +| `open` | `opn` | Opens a new file, Only C++/Java/Python files will be opened. Without arguments it is same as open in Action menu. | `open` or `opn ~/cf/a.cpp` | +| `compile` | `cmp` | Compiles the code, It is like clicking "Compile" button in a tab. | `compile` or `cmp` | +| `crun` | `crn` | Compiles and run, It is like clicking "Compile and Run" button in a tab. | `crun` or `crn` | +| `run` | `run` | Run, if no argument is provided all testcases are ran, otherwise nth testcase is ran. Counting includes hidden testcases. | `run` or `run 2` | +| `drun` | `drn` | Detached run, It is same as clicking "Detached Run" in menu. | `drun` or `drn` | +| `killall` | `kap` | Kill all process, It is same as clicking "Kill Process" in menu | `killall` or `kap` | +| `format` | `fmt` | Format Code, It is same as clicking "Format Code" in menu | `format` or `fmt` | +| `snippet` | `snp` | Open snippet dialog, It is same as clicking "Use Snippets" in menu | `snippet` or `snp` | +| `vmode` | `vmd` | View mode, Changes the view mode. It can only toggle to "edit" and "split" mode | `vmode edit` or `vmd split` | +| `preference` | `prf` | Preferences, It is same as clicking "Preference" in menu | `preference` or `prf` | +| `chlang` | `chl` | Language, It can be used to change the language of a tab. | `chlang cpp` or `chl java` | +| `clear` | `clr` | Clear Message logger text | `clear` or `clr` | +| `exit` | `ext` | Exit, It is same as pressing "Quit" in menu. | `exit` or `ext` | diff --git a/content/docs/tips/_index.md b/content/docs/tips/_index.md index b84e79708..86b503fa8 100644 --- a/content/docs/tips/_index.md +++ b/content/docs/tips/_index.md @@ -70,6 +70,12 @@ You can use Ctlr+Tab and Ctlr+Shift+Tab to go through the You can set a hotkey for switching view modes in [Preferences](../preferences/key-bindings/\_index.md). +## Vim Emulation + +You can enable vim emulation in code editor. Most [basic vim commands](../preferences/code-edit/\_index.md#vim-commands) and some [custom vim commands](../preferences/code-edit/\_index.md#custom-vim-commands) to perform various actions are supported. Many code editor settings like Tab width, Indentation, Current Line Highlight etc are disabled when using vim mode, you have to customize them from [Vim Configuration](../preferences/code-editing/\_index.md#vim-configuration). + +You can switch to next or previous tab using `tabn` and `tabp` respectively. + ## Launch CP Editor in the command line CP Editor supports some command-line options, run `cpeditor --help` for more information. From e802b7ef822b3de0b6851c16f1bcc59bfcec30f9 Mon Sep 17 00:00:00 2001 From: mohammadkhan Date: Sat, 16 Dec 2023 23:49:21 +0530 Subject: [PATCH 2/3] fix: broken link --- content/docs/preferences/code-edit/_index.md | 2 +- content/docs/tips/_index.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/content/docs/preferences/code-edit/_index.md b/content/docs/preferences/code-edit/_index.md index 8b8834517..6e65179fc 100644 --- a/content/docs/preferences/code-edit/_index.md +++ b/content/docs/preferences/code-edit/_index.md @@ -52,7 +52,7 @@ If enabled, code editor will emulate vim behaviour. In vim emulation, Control Ke ### Vim configuration -The configuration to use in vim mode. The list of all supported vim commands are listed [here](../general/\_index.md#vim-commands) +The configuration to use in vim mode. The list of all supported vim commands are listed [here](#vim-commands) ### Vim Commands diff --git a/content/docs/tips/_index.md b/content/docs/tips/_index.md index 86b503fa8..5e7d40ed7 100644 --- a/content/docs/tips/_index.md +++ b/content/docs/tips/_index.md @@ -72,7 +72,7 @@ You can set a hotkey for switching view modes in [Preferences](../preferences/ke ## Vim Emulation -You can enable vim emulation in code editor. Most [basic vim commands](../preferences/code-edit/\_index.md#vim-commands) and some [custom vim commands](../preferences/code-edit/\_index.md#custom-vim-commands) to perform various actions are supported. Many code editor settings like Tab width, Indentation, Current Line Highlight etc are disabled when using vim mode, you have to customize them from [Vim Configuration](../preferences/code-editing/\_index.md#vim-configuration). +You can enable vim emulation in code editor. Most [basic vim commands](../preferences/code-edit/\_index.md#vim-commands) and some [custom vim commands](../preferences/code-edit/\_index.md#custom-vim-commands) to perform various actions are supported. Many code editor settings like Tab width, Indentation, Current Line Highlight etc are disabled when using vim mode, you have to customize them from [Vim Configuration](../preferences/code-edit/\_index.md#vim-configuration). You can switch to next or previous tab using `tabn` and `tabp` respectively. From a0ac9af89621faa8ab4fe1c3c95b48b2309b10a8 Mon Sep 17 00:00:00 2001 From: Ashar Date: Sun, 5 Apr 2026 19:40:11 +0530 Subject: [PATCH 3/3] fix(docs): improve vim documentation quality - Fix QRegExp reference (now QRegularExpression) - Fix 'langauge' typos - Fix confusing wording about control key interception - Fix grammar and punctuation throughout - Capitalize 'Vim Configuration' to match setting name - Add colon prefix to :tabn/:tabp (they are ex-commands) - Clean up custom commands table descriptions for consistency --- content/docs/preferences/code-edit/_index.md | 42 ++++++++++---------- content/docs/tips/_index.md | 4 +- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/content/docs/preferences/code-edit/_index.md b/content/docs/preferences/code-edit/_index.md index 6e65179fc..ca72d03f3 100644 --- a/content/docs/preferences/code-edit/_index.md +++ b/content/docs/preferences/code-edit/_index.md @@ -48,19 +48,19 @@ Note that this won't replace the existing tab characters. In [Auto Indent](#auto ### Enable Vim emulation -If enabled, code editor will emulate vim behaviour. In vim emulation, Control Key such as Ctrl+N will not be intercepted by CP Editor but by Code Editor. We provide some custom commands that can perform various tasks like opening new tab, running testcases etc. [Here](#custom-vim-commands) is a list of all supported custom vim commands. +If enabled, the code editor will emulate vim behaviour. In vim emulation, control keys such as Ctrl+N will be handled by the vim layer instead of CP Editor's default key bindings. We provide some custom commands that can perform various tasks like opening new tabs, running test cases, etc. [Here](#custom-vim-commands) is a list of all supported custom vim commands. -### Vim configuration +### Vim Configuration -The configuration to use in vim mode. The list of all supported vim commands are listed [here](#vim-commands) +The configuration to use in vim mode. The list of all supported vim commands is [here](#vim-commands). ### Vim Commands #### Supported Features -Most of supported commands can be followed by motion command or executed in visual mode, work with registers or can be prefixed with number of repetitions. +Most supported commands can be followed by a motion command or executed in visual mode, work with registers, or be prefixed with a number of repetitions. -Here is list of emulated commands with description where it can diverge from Vim in functionality. +Here is a list of emulated commands with notes where behaviour can diverge from Vim. #### Modes @@ -81,7 +81,7 @@ Here is list of emulated commands with description where it can diverge from Vim - undo/redo - ``, `` -- increase or decrease number in decimal/octal/hexadecimal format (e.g. `128` on or before "0x0ff" changes it to "0x17f") - `.` -- repeat last change -- `/search`, `?search`, `*`, `#`, `n`, `N` -- most of regular expression syntax used in Vim except `\<` and `\>` just is the same as `\b` in QRegExp +- `/search`, `?search`, `*`, `#`, `n`, `N` -- most of the regular expression syntax used in Vim is supported; `\<` and `\>` are equivalent to `\b` - `@`, `q` (macro recording, execution) -- special keys are saved as `` - marks - `gv` -- last visual selection; can differ if text is edited around it @@ -180,21 +180,21 @@ vnoremap :m-2gv=gv ### Custom Vim commands -In this section we present a list of all custom vim commands that are supported to perform different operation in CP Editor. +In this section we present a list of all custom vim commands supported in CP Editor. | Command | Shorthand | Description | Usage | | :----------: | :-------: | :-----------------------------------------------------------------------------------------------------------------------: | :-------------------------: | -| `new` | `new` | Opens a new tab, if no langauge is specified, a tab in default editor langauge will open | `new cpp` or `new` | -| `open` | `opn` | Opens a new file, Only C++/Java/Python files will be opened. Without arguments it is same as open in Action menu. | `open` or `opn ~/cf/a.cpp` | -| `compile` | `cmp` | Compiles the code, It is like clicking "Compile" button in a tab. | `compile` or `cmp` | -| `crun` | `crn` | Compiles and run, It is like clicking "Compile and Run" button in a tab. | `crun` or `crn` | -| `run` | `run` | Run, if no argument is provided all testcases are ran, otherwise nth testcase is ran. Counting includes hidden testcases. | `run` or `run 2` | -| `drun` | `drn` | Detached run, It is same as clicking "Detached Run" in menu. | `drun` or `drn` | -| `killall` | `kap` | Kill all process, It is same as clicking "Kill Process" in menu | `killall` or `kap` | -| `format` | `fmt` | Format Code, It is same as clicking "Format Code" in menu | `format` or `fmt` | -| `snippet` | `snp` | Open snippet dialog, It is same as clicking "Use Snippets" in menu | `snippet` or `snp` | -| `vmode` | `vmd` | View mode, Changes the view mode. It can only toggle to "edit" and "split" mode | `vmode edit` or `vmd split` | -| `preference` | `prf` | Preferences, It is same as clicking "Preference" in menu | `preference` or `prf` | -| `chlang` | `chl` | Language, It can be used to change the language of a tab. | `chlang cpp` or `chl java` | -| `clear` | `clr` | Clear Message logger text | `clear` or `clr` | -| `exit` | `ext` | Exit, It is same as pressing "Quit" in menu. | `exit` or `ext` | +| `new` | `new` | Opens a new tab. If no language is specified, the default editor language is used. | `new cpp` or `new` | +| `open` | `opn` | Opens a file. Only C++/Java/Python files are supported. Without arguments, opens the file dialog. | `open` or `opn ~/cf/a.cpp` | +| `compile` | `cmp` | Compiles the code. Same as clicking the "Compile" button. | `compile` or `cmp` | +| `crun` | `crn` | Compiles and runs. Same as clicking the "Compile and Run" button. | `crun` or `crn` | +| `run` | `run` | Runs test cases. Without arguments, runs all checked test cases. With a number, runs that specific test case. | `run` or `run 2` | +| `drun` | `drn` | Detached run. Same as clicking "Detached Run" in the menu. | `drun` or `drn` | +| `killall` | `kap` | Kills all running processes. Same as clicking "Kill Processes" in the menu. | `killall` or `kap` | +| `format` | `fmt` | Formats the code. Same as clicking "Format Code" in the menu. | `format` or `fmt` | +| `snippet` | `snp` | Opens the snippet dialog. Same as clicking "Use Snippets" in the menu. | `snippet` or `snp` | +| `vmode` | `vmd` | Changes the view mode. Supports "edit" and "split" modes. | `vmode edit` or `vmd split` | +| `preference` | `prf` | Opens the preferences window. | `preference` or `prf` | +| `chlang` | `chl` | Changes the language of the current tab. | `chlang cpp` or `chl java` | +| `clear` | `clr` | Clears the message logger. | `clear` or `clr` | +| `exit` | `ext` | Exits CP Editor. Same as clicking "Quit" in the menu. | `exit` or `ext` | diff --git a/content/docs/tips/_index.md b/content/docs/tips/_index.md index 0457b7578..9d20186b0 100644 --- a/content/docs/tips/_index.md +++ b/content/docs/tips/_index.md @@ -72,9 +72,9 @@ You can set a hotkey for switching view modes in [Preferences](../preferences/ke ## Vim Emulation -You can enable vim emulation in code editor. Most [basic vim commands](../preferences/code-edit/\_index.md#vim-commands) and some [custom vim commands](../preferences/code-edit/\_index.md#custom-vim-commands) to perform various actions are supported. Many code editor settings like Tab width, Indentation, Current Line Highlight etc are disabled when using vim mode, you have to customize them from [Vim Configuration](../preferences/code-edit/\_index.md#vim-configuration). +You can enable vim emulation in the code editor. Most [basic vim commands](../preferences/code-edit/\_index.md#vim-commands) and some [custom vim commands](../preferences/code-edit/\_index.md#custom-vim-commands) to perform various actions are supported. Many code editor settings like tab width, indentation, and current line highlighting are managed by vim when vim mode is enabled — customize them in [Vim Configuration](../preferences/code-edit/\_index.md#vim-configuration). -You can switch to next or previous tab using `tabn` and `tabp` respectively. +You can switch to the next or previous tab using `:tabn` and `:tabp` respectively. ## Launch CP Editor in the command line