• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Line Numbers in VI and/or Visual C++ :: C++

kuphryn

Senior member
Hi.

I always find myself counting the number of lines in my code when GNU C++ gives me errors with line numbers. However, counting is a slow and tedious in Linux C++ editors such as VI. I saw someone use a Linux C++ editor with line numbers on the left. I am not sure what editor he was using, but I believe it was VI.

How do you enable line numbers inside VI C++ editor? Is it possible to view line numbers in Visual C++ as well? Microsoft makes Visual C++ extremely user friend as it directly focuses to the error line when the user double-click on the error. Nonetheless, since Linux C++ editors such as VI do not have that feature, I would like to try and practice debugging using line numbers.

Thanks,
Kuphryn
 
vi normally has the line you are currently on indicated in the lower corner (not sure which side). Same with Emacs. In Emacs I think you can jump to a like by doing ctrl-\ then g then the line number. In visual C++ you can press ctrl-g then enter the line number. Line number also shows up at the bottom in VC++.
 
In VI/VIM just type..

:set nu

or

:set number


to turn it of...

:set nonu

or

:set nonumber



You can also get the current line number at any time in vi by hitting CONTROL-G
 
also in vi, you can use
:n (where n is the line number) to go straight to line n
or you can also do n + shift-G to go to line n as well (press the line number, then shift-g)

to go to the end of file
: and enter, or just plain shift-G

🙂
-931-
 
Back
Top